bcrypt does not work on lambda serverless

Viewed 5656

I added the bcrypt module, in local it works, but it does not work when I deploy I test the function and show this:

errorMessage": "/var/task/node_modules/bcrypt/lib/binding/bcrypt_lib.node: invalid ELF header
2 Answers

You need to deploy using linux environment. If you deploy it from windows machine this error occurred.

Alternatively you can use bcryptjs instead of bcrypt

For the python version of this issue (how I ended up here) you need to install the linux version of the package (as well as cffi, cryptography, and PyNaCl which it relies on) and unzip them yourself.

You can do this with:

pip download PyNaCl --platform manylinux1_x86_64 --no-deps -d lambda_project/python/lib/python3.8/site-packages
pip download cffi --platform manylinux1_x86_64 --no-deps -d lambda_project/python/lib/python3.8/site-packages
pip download bcrypt --platform manylinux1_x86_64 --no-deps -d lambda_project/python/lib/python3.8/site-packages
pip download cryptography --platform manylinux2014_x86_64 --no-deps -d lambda_project/python/lib/python3.8/site-packages

cd lambda_project/python/lib/python3.8/site-packages
unzip \*.whl
rm *.whl
Related