Node.bcrypt.js: Bcrypt fails to install via npm

Created on 1 Jun 2017  路  37Comments  路  Source: kelektiv/node.bcrypt.js

I run a package called mStream that uses bcrypt. Several users have reported that when installing mStream via npm they get the following bcrypt error:

npm ERR! Linux 4.4.0-78-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "mstream"
npm ERR! node v7.10.0
npm ERR! npm  v4.2.0
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 'node-pre-gyp install --fallback-to-build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the bcrypt package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-pre-gyp install --fallback-to-build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs bcrypt
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls bcrypt
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /root/.npm/_logs/2017-05-31T19_40_42_507Z-debug.log

The workaround is pretty easy luckily. If you clone the repository via github and run npm install bcrypt will install just fine. Any idea what's causing this bug?

Most helpful comment

Following steps saved my day:

  • npm uninstall bcrypt -S or remove bcrypt from package.json
  • Deleted package-lock.json
  • npm i bcrypt@latest -S

All 37 comments

The output for me:

> [email protected] install /Users/dwas/Projects/BMW/cml-dashboard-backend/node_modules/bcrypt
> node-pre-gyp install --fallback-to-build

node-pre-gyp info it worked if it ends with ok
node-pre-gyp verb cli [ '/usr/local/Cellar/node/7.9.0/bin/node',
node-pre-gyp verb cli   '/Users/dwas/Projects/BMW/cml-dashboard-backend/node_modules/.bin/node-pre-gyp',
node-pre-gyp verb cli   'install',
node-pre-gyp verb cli   '--fallback-to-build' ]
node-pre-gyp info using node-pre-gyp@https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.6.32.tgz
node-pre-gyp info using [email protected] | darwin | x64
node-pre-gyp verb command install []
node-pre-gyp ERR! install error 
node-pre-gyp ERR! stack TypeError: Cannot read property 'version' of null
node-pre-gyp ERR! stack     at Object.module.exports.evaluate (/Users/dwas/Projects/BMW/cml-dashboard-backend/node_modules/node-pre-gyp/lib/util/versioning.js:270:32)
node-pre-gyp ERR! stack     at install (/Users/dwas/Projects/BMW/cml-dashboard-backend/node_modules/node-pre-gyp/lib/install.js:168:31)
node-pre-gyp ERR! stack     at Object.self.commands.(anonymous function) [as install] (/Users/dwas/Projects/BMW/cml-dashboard-backend/node_modules/node-pre-gyp/lib/node-pre-gyp.js:50:37)
node-pre-gyp ERR! stack     at run (/Users/dwas/Projects/BMW/cml-dashboard-backend/node_modules/node-pre-gyp/bin/node-pre-gyp:79:30)
node-pre-gyp ERR! stack     at Object.<anonymous> (/Users/dwas/Projects/BMW/cml-dashboard-backend/node_modules/node-pre-gyp/bin/node-pre-gyp:131:1)
node-pre-gyp ERR! stack     at Module._compile (module.js:571:32)
node-pre-gyp ERR! stack     at Object.Module._extensions..js (module.js:580:10)
node-pre-gyp ERR! stack     at Module.load (module.js:488:32)
node-pre-gyp ERR! stack     at tryModuleLoad (module.js:447:12)
node-pre-gyp ERR! stack     at Function.Module._load (module.js:439:3)
node-pre-gyp ERR! System Darwin 16.6.0
node-pre-gyp ERR! command "/usr/local/Cellar/node/7.9.0/bin/node" "/Users/dwas/Projects/BMW/cml-dashboard-backend/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /Users/dwas/Projects/BMW/cml-dashboard-backend/node_modules/bcrypt
node-pre-gyp ERR! node -v v7.9.0
node-pre-gyp ERR! node-pre-gyp -v vhttps://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.6.32.tgz
node-pre-gyp ERR! not ok 
Cannot read property 'version' of null
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.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/dwas/.npm/_logs/2017-06-02T14_04_12_571Z-debug.log

We had a similar problem on our project after upgrading to npm v5. Explicitly installing bcrypt (ie npm install bcrypt) was a workaround. Not sure how to tell if this is an npm v5 issue or bcrypt, so I apologize if this comment is creating more noise ;)

This as is really a npm v5 bug with node-pre-gyp https://github.com/npm/npm/issues/16728
I would suggest to avoid npm5 for now, or as a workaround, explicitly list bcrypt as the list of dependencies.

This issue has disappeared in recent versions of npm, though I cannot confirm.

It has certainly disappeared for us, somewhere at approximately npm v5.3.

There were some bug-fixes in npm regarding this, though the linked issue remains open.
Will reopen this issue, if the issue reappears.

Run into same issue while npm install after pulling master branch, as well as on npm install bcrypt

> [email protected] install /home/paulo/Documents/Projects/lara/node_modules/bcrypt
> node-pre-gyp install --fallback-to-build

sh: 1: node-pre-gyp: not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! [email protected] install: `node-pre-gyp install --fallback-to-build`
npm ERR! spawn ENOENT
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.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/paulo/.npm/_logs/2017-09-24T06_26_00_050Z-debug.log1

Found a workaround though; run npm install bcrypt before running npm install

The problem still occurs - when I tried to deploy my app to Digital Ocean I received exactly the same error log (npm 5.5.1)

@Rachomir, Do you have build-essentials and python ?
You shouldn't receive this error, as node-pre-gyp will not attempt to rebuild the binaries. We already have compatible binaries uploaded.

Still some more info, and the np,-debug.log will help

What I am receiving is

p install --fallback-to-build`
npm ERR! Exit status 2
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.

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2017-11-06T15_08_43_688Z-debug.log
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
npm WARN [email protected] No license field.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] install: node npm-rebuild.js
npm ERR! Exit status 2
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.

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2017-11-06T15_08_43_798Z-debug.log

I red in another source in the internet that bcryptjs will work fine and it does however afterwards I had a problem with chromedriver script... any idea how to fix it?

@Rachomir bcryptjs is a different library, it uses slower javascript bcrypt implementation.

Please attach the contents of "/root/.npm/_logs/2017-11-06T15_08_43_798Z-debug.log"

Don't know if it's a right place to report, but I can also confirm similar problem. I use a fresh DO instance with Ubuntu 16.04.3 and latest Node (9.3.0) and NPM (5.5.1) versions. This problem occurs when I do the "npm install" for a Meteor project build.

@themao what version of Meteor are you using?

@Rachomir it's 1.5.1

What about docker image?

@Rachomir I don't use docker in my current setup, but maybe I should try

Using Docker from node:8 I get more weird error:

events.js:183
throw er; // Unhandled 'error' event
^

Error: spawn npm ENOENT
at _errnoException (util.js:1024:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
at onErrorNT (internal/child_process.js:372:16)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
at Function.Module.runMain (module.js:678:11)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: node npm-rebuild.js
npm ERR! Exit status 1
npm ERR!

It's odd, but installing bcrypt globally and removing it from package.json didn't help - it still tries to install bcrypt and fails

Wait, the error message actually changed. Now it's about the fibers package. So I assume it has nothing to do with some package, just a general npm/node problem.

So, I "solved" it by downgrading to npm 3.10.3 and node 6.4.0

Having exactly the same error using Meteor Up and DO. Node 8.x and NPM 5.5
I will pursue trying to get a fix using these versions instead of downgrading. If I find anything I will post here

I have the same issue. Tried with multiple versions of node and npm (4.7, 6.4, 9.4). Every time I got the same problem

@nicolas-mosch EPERM?

Seeing the same issue.

Finally after many research I solve this problem. So, guys those who are facing this problem just do the below processes,

I just installed python and set the environment variables now it's working perfect for me.

Install Python (while installing in windows you can get the option for add path in environment variables, just tick the check box or else)
Set the path in environment variables
Now store the downloaded python.exe file in this directory "c:\Python\27\python.exe"
Now run this cmd in terminal npm config set python "c:\Python\27\python.exe"
Now do npm install or run your project.
guys just check it out may be you solve your problem :)

Hi guys... I had the same problem... I hope it helps someone because I lost hours with this, but instead of using bcrypt I've used bcryptjs (found here)

So instead of using:
const bcrypt = require('bcrypt');
I'm using
const bcrypt = require('bcryptjs');

I read that is a little bit less performant. At least for my application it works great without further problems.

I hope it helps.

Try add bcryptto _package.json_ and after execute npm install.

This worked for me!

Trying to get a year old program to install, "npm upgrade" failed, had to manually change ""bcrypt": "^1.0.3", to ""bcrypt": "^3.0.2", was getting 404 errors when 1.0.3 was part of the download url

For me, it was to make python 2.7 as the node python version. My problem was that I had python 3.4 which is unsupported based on node-gyp npm page.

Manually changing "bcrypt":"^1.0.3" to "bcrypt":"^3.0.2" in the package.json worked fine for me.

Manually changing "bcrypt":"^1.0.3" to "bcrypt":"^3.0.2" in the package.json worked fine for me.

It worked ! Thanks a lot

I had the same problem. changing the bcrypt version to latest(3.0.6) worked for me.

Following steps saved my day:

  • npm uninstall bcrypt -S or remove bcrypt from package.json
  • Deleted package-lock.json
  • npm i bcrypt@latest -S

Thank you! This worked!

FWIW, fixed it by running

npm rebuild
npm install

YMMV, as we all know npm works in mysterious ways.

Edit:

Alternative that seemed to have worked as well (source)

npm rebuild bcrypt --update-binary

Although I don't really see this parameter in the documentation...

Following steps saved my day:

  • npm uninstall bcrypt -S or remove bcrypt from package.json
  • Deleted package-lock.json
  • npm i bcrypt@latest -S

This worked for me! Thanks

Manually changing "bcrypt":"^1.0.3" to "bcrypt":"^3.0.2" in the package.json worked fine for me.

This worked for me! Thanks

Was this page helpful?
0 / 5 - 0 ratings