0

My question is similar to an existing one, but I'm using webpack and thus don't even have a "node_modules" directory.

I've still tried the following environment variable settings without success:

NODE_ICU_DATA: 'node_modules/full-icu'
NODE_ICU_DATA: '/var/task/node_modules/full-icu/icudt58l.dat'
NODE_ICU_DATA: '/var/task/node_modules/full-icu/icudt60l.dat'

All without success, the lambdas simply refuse to start and a log message is show in CloudWatch:

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

I found very little about this problem on Google, which seems curious given that it should concern so many that are building internal apps on AWS lambda.

kossmoboleat
  • 1,841
  • 1
  • 19
  • 36
  • Someone else also posted the question to the full-icu's github repository and didn't get a response: https://github.com/unicode-org/full-icu-npm/issues/31 – kossmoboleat Apr 30 '19 at 08:27

1 Answers1

1

Make sure you're deploying the correct .dat file version into the directory defined by NODE_ICU_DATA. In my case, the correct file was icudt62l.dat when using the runtime nodejs10.x for my lambdas. If you're not deploying node_modules as part of your lambda, you can grab the correct .dat file and deploy that.

I ran into the same error message when upgrading the runtime version of some old lambdas from nodejs6.10 to nodejs10.x. In my case, the file icudt58l.dat (compatible with nodejs6.10) was deployed into the project root, and the value of NODE_ICU_DATA was . (i.e. the directory where my lambda executes, equivalent to /var/task/).

To get a compatible .dat file, I re-installed the full-icu package using the node version used by the lambdas:

npx -p node@10.x npm i full-icu

It's important that the version of the .dat file is correct for the runtime version your lambdas are using. Initially, I made the mistake of just running npm i full-icu using node version 10.0 but this installed the wrong version of the .dat file and I just got the same error message again.

Finally, I copied the file node_modules/full-icu/icudt62l.dat into the project root and deleted the old icudt58l.dat so that it ends up in /var/task/ where the lambda can find it when NODE_ICU_DATA=..

avj
  • 31
  • 5