Issue
This is the error shown while running.
On bcrypt's GitHub wiki, they say that it is a native module for node-js and that it requires a compiler and build dependencies in order to build. What am I doing wrong, can someone please help me
{
"errorType": "Error",
"errorMessage": "/var/task/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node: invalid ELF header",
"stack": [
"Error: /var/task/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node: invalid ELF header",
" at Object.Module._extensions..node (internal/modules/cjs/loader.js:1057:18)",
" at Module.load (internal/modules/cjs/loader.js:863:32)",
" at Function.Module._load (internal/modules/cjs/loader.js:708:14)",
" at Module.require (internal/modules/cjs/loader.js:887:19)",
" at require (internal/modules/cjs/helpers.js:74:18)",
" at Object.<anonymous> (/var/task/node_modules/bcrypt/bcrypt.js6️⃣16)",
" at Module._compile (internal/modules/cjs/loader.js:999:30)",
" at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)",
" at Module.load (internal/modules/cjs/loader.js:863:32)",
" at Function.Module._load (internal/modules/cjs/loader.js:708:14)"
]
}
Solution
I was having the same problem,solved it by using **bcryptjs** (npm i bcryptjs)
instead of bcrypt package.
It appears bcrypt fails on lambda because it uses node-gyp to build and install - not sure though will have to work though it.
Until then, bcryptjs works.
Answered By - Harsh.K