0

I am trying to make my express.js app works on AWS Lambda. The deployment (using serverless framework completes successfully, however the app returns a 500 internal error when I test my requests. My logs shows me this error :

/var/task/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node: invalid ELF header.

I've tried to replace bcrypt with bcryptjs but the problem persists.

Also, in my serverless.yml, I've added the following line to force lambda to install bcrypt by itself, but apparently it didn't make the trick :

package:
  exclude:
    - node_modules/**

Any suggestion ?

John doe
  • 3,025
  • 4
  • 20
  • 44

1 Answers1

0

First, please include node modules. AWS won't install anything into the lambda node env besides the aws-sdk.

Secondly, you're seeing this error because your likely developing on a mac OS machine, so the bycrypt binary from your machine is ending up getting uploaded to lambda.

Please double check that when you tried bcryptjs, you fully removed bcrypt from your project dependencies.

Aaron Stuyvenberg
  • 1,563
  • 3
  • 13