Reputation: 6664
I have a node application deployed to aws elastic beanstalk, using the latest platform (Nodejs running on 64bit Amazon Linux/4.9.2) and the latest available node version (10.16.0)
In the package.json file, as long as I am installing bcrypt ^2.0.1, everything works great.
However, if I try to update to the latest version of bcrypt ^3.0.6, elastic beanstalk fails during deploy with the following error:
Error: Cannot find module '../'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:690:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/tmp/deployment/application/node_modules/.bin/node-pre-gyp:15:20)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
On bcrypt's site there is mention of a permissions issue with aws and bcrypt, and a suggested fix. However, the fix did not work for me. This seems to be a different problem.
Has anyone else encountered this before?
Upvotes: 2
Views: 1975
Reputation: 167
We can resolve this issue by installing already compiled version of bcrypt that is 'bcryptjs' in your project.I had similar issue in AWS, that got resolved by this method(bcryptjs version:2.4.3).
npm install --save bcryptjs
Upvotes: 0
Reputation: 31
Packages that do image manipulation and encryption like bcrypt and sharp required additional permissions. So, you have to create a .npmrc file and give access to run them as root in the server. This way, you won't get permission denied error and automatically installs such packages.
In the .npmrc file paste the following
#Force npm to run node-gyp also as root, preventing permission denied errors in AWS with npm@5
unsafe-perm=true
Now, your bcrypt will be installed without any hiccups.
Upvotes: 1
Reputation: 116
I had the same issue, in my case, the problem was not related to bcrypt but to node-gyp not bein able to create a temporal directory for the install
my fix was changing bcrypt to bcryptjs wich is an updated version of that package
another workaround would be adding a .npmrc file in the build of your app with the following content: unsafe-perm=true
this will allow npm to run always as root
Upvotes: 0
Reputation: 506
Try to use bcryptjs module instead of bcrypt which is an update/latest npm module.
Run npm install bcryptjs and then npm install Originally answered here
Upvotes: 0
Reputation: 21
bcrypt version 3.0.5 with Node 10 has the same issue. I had to downgrade bcrypt to version 3.0.4
What is strange is that current bcrypt documentation on npm says that 3.0.6 is for Node 12 but documentation from previous bcrypt version says that 3.0.5 is for Node 12.
Upvotes: 1
Reputation: 21
Downgrade to a bcrypt version between 3.0.0 and 3.0.5. I experienced the same issue when running with Node versions 10.14.x to 10.16.x
I believe bcrypt 3.0.6 is for Node version >= 12.x
Upvotes: 1