AWS Lambda Node.js Full-ICU [英] AWS Lambda Node.js Full-ICU
问题描述
我使用以下命令在本地运行node.js应用程序:
I run node.js app localy with this command:
$ node --icu-data-dir=node_modules/full-icu app.local.js
如何在AWS Lambda环境中指定icu-data-dir?
How to specify icu-data-dir in AWS Lambda environment?
谢谢
推荐答案
您应该设置NODE_ICU_DATA
环境变量,以便它指向可以找到正确的ICU .dat
文件的目录.
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.
如果使用与lambda所使用的节点版本匹配的节点版本安装full-icu
软件包,则应自动获取正确的.dat
文件.例如.使用运行时nodejs10.x
时:
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
这将安装node_modules/full-icu/
,您应该在该目录中看到文件icudt62l.dat
.文件的确切名称取决于您使用的节点的版本.
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.
如果将整个node_modules
目录作为lambda的一部分进行部署,则NODE_ICU_DATA=node_modules/full-icu/
(相当于NODE_ICU_DATA=/var/task/node_modules/full-icu
)应该可以工作.否则,您可以仅将.dat
文件作为lambda的一部分进行部署,并将NODE_ICU_DATA
指向部署文件的目录.
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.
如果仍然出现错误,并且确定NODE_ICU_DATA
正确,请确保.dat
文件版本正确.
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.
这篇关于AWS Lambda Node.js Full-ICU的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!