Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Lambda Node.js Full-ICU

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

like image 320
Luke1988 Avatar asked Nov 21 '25 19:11

Luke1988


1 Answers

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 [email protected] 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.

like image 188
avj Avatar answered Nov 23 '25 10:11

avj



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!