node: could not initialize ICU (check NODE_ICU_DATA or --icu-data-dir parameters)

丶灬走出姿态 提交于 2019-12-04 02:53:59

问题


I was trying to upgrade node version on our CI environment from node 6 to node 8. I updated the full-icu version as well.

the $NODE_ICU_DATA is set to /usr/lib/node_modules/full-icu

but still get this error

node: could not initialize ICU (check NODE_ICU_DATA or --icu-data-dir parameters)

Any idea, how to fix this?


回答1:


You need to run npm install including the full-icu package. It's full-icu's postinstall step which downloads the appropriate bits for the currently executing node. Note that multiple files may show up in the full-icu directory, that's OK.




回答2:


If you already had full-icu installed, but did upgrade node in between:

npm rebuild does fix the issue.




回答3:


If you want use Node.js with full-icu and Docker, you can use example of Dockerfile:

FROM node:lts-alpine

WORKDIR /icu
RUN npm init -y && npm install full-icu
ENV NODE_ICU_DATA=/icu/node_modules/full-icu

WORKDIR /project
COPY package*.json ./
RUN npm install
COPY . .

EXPOSE 8080
CMD [ "node", "server.js" ]

It's works for me.



来源:https://stackoverflow.com/questions/50296555/node-could-not-initialize-icu-check-node-icu-data-or-icu-data-dir-parameters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!