DarkSun
DarkSun

Reputation: 449

npm install with AWS Lambda

I'm writing AWS Lambda function in Javascript. I need to use synchronize.js library, so I ran npm install synchronize. Everything works fine locally, but when I upload *.zip to AWS and run, it thorws the following error:

  "errorMessage": "`/var/task/node_modules/fibers/bin/linux-x64-v8-3.14/fibers.node` is missing. Try reinstalling `node-fibers`?"

I think it expects different binaries version installed by npm. How can I fix it?

Upvotes: 3

Views: 5235

Answers (1)

Todd Price
Todd Price

Reputation: 2760

Because AWS Lambda does not execute npm install for you, any npm module that requires a binary build step can run into issues depending on the module's functionality, how it builds, etc. I'm not familiar with synchronize.js, but it likely needs to be built on Amazon Linux to succeed inside AWS Lambda.

So you must either:

  1. Do your npm install synchronize on a machine running Amazon Linux, and deploy from there.
  2. Replace synchronize.js with async code (callbacks, promises or async library)

In general I'd recommend #2 if at all possible. You don't actually ask a specific question so I'm not positive that would work for you, but hopefully this gives you some direction.

Upvotes: 2

Related Questions