I run node.js app localy with this command:
$ node --icu-data-dir=node_modules/full-icu app.local.js
How to specify icu-data-dir in AWS Lambda environment?
Thanks
You should set the NODE_ICU_DATA
environment variable so that it points to a directory where the correct ICU .dat
file can be found.
If you install the full-icu
package using the node version that matches the one used by your lambdas, you should automatically get the correct .dat
file. E.g. when using the runtime nodejs10.x
:
npx -p node@10.x npm i full-icu
This installs node_modules/full-icu/
, and you should see the file icudt62l.dat
in that directory. The exact name of the file depends on the version of node you're using.
If you're deploying the whole node_modules
directory as part of your lambda, NODE_ICU_DATA=node_modules/full-icu/
(equivalent to NODE_ICU_DATA=/var/task/node_modules/full-icu
) should work. Otherwise, you can deploy just the .dat
file as part of your lambda and point NODE_ICU_DATA
at the directory where you deployed the file.
If you're still getting an error and you're sure that NODE_ICU_DATA
is correct, make sure that the .dat
file version is correct.
As pointed in the node.js docs, you can also use an environment variable, such as NODE_ICU_DATA=/some/directory
.
You can easily setup environment variables in your lambda instance settings.
来源:https://stackoverflow.com/questions/49195309/aws-lambda-node-js-full-icu