Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 679
Pooja Gurav Avatar asked May 11 '18 16:05

Pooja Gurav


3 Answers

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.

If you already had full-icu installed, but upgraded Node.js in between:

npm rebuild 

fixes the issue.

like image 168
Steven R. Loomis Avatar answered Oct 12 '22 07:10

Steven R. Loomis


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

npm rebuild does fix the issue.

like image 28
line-o Avatar answered Oct 12 '22 09:10

line-o


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.

like image 39
Valeriy Sotnikov Avatar answered Oct 12 '22 09:10

Valeriy Sotnikov