Cannot install bcrypt node.js module on Centos Server

I am trying to install bcrypt on a CentOS server, but I got the following error:

info postuninstall bcrypt@0.5.0 ERR! bcrypt@0.5.0 install: `make build` ERR! `sh "-c" "make build"` failed with 2 ERR! ERR! Failed at the bcrypt@0.5.0 install script. ERR! This is most likely a problem with the bcrypt package, ERR! not with npm itself. ERR! Tell the author that this fails on your system: ERR! make build ERR! You can get their info via: ERR! npm owner ls bcrypt ERR! There is likely additional logging output above. ERR! ERR! System Linux 2.6.18-028stab095.1 ERR! command "nodejs" "/usr/bin/npm" "install" "bcrypt" ERR! cwd /root/grouplo ERR! node -v v0.6.15 ERR! npm -v 1.1.16 ERR! code ELIFECYCLE ERR! message bcrypt@0.5.0 install: `make build` ERR! message `sh "-c" "make build"` failed with 2 ERR! errno {} 

What can I do to solve this problem? Thanks,

+8
bcrypt npm centos
source share
3 answers

I have the same problem as npm install bcrypt. Another option is to install it from the source.

 git clone git://github.com/ncb000gt/node.bcrypt.js.git cd node.bcrypt.js node-gyp configure node-gyp build 

Rename the node.bcrypt.js folder to bcrypt and move it to your node_modules of your project.

You can install node -gyp by running npm install -g node -gyp (-g installs it globally).

+5
source share

There is also a version of bcrypt native-js that does not require compilation. https://github.com/shaneGirish/bcrypt-nodejs

 npm install bcrypt-nodejs 

Api is very similar to the compiled version. The following is taken directly from readme

Main use:

Synchronous

 var hash = bcrypt.hashSync("bacon"); bcrypt.compareSync("bacon", hash); // true bcrypt.compareSync("veggies", hash); // false 

Asynchronous

 bcrypt.hash("bacon", null, null, function(err, hash) { // Store hash in your password DB. }); // Load hash from your password DB. bcrypt.compare("bacon", hash, function(err, res) { // res == true }); bcrypt.compare("veggies", hash, function(err, res) { // res = false }); 
+11
source share

For me, the answer was to make sure gcc, openssl and node -gyp were installed.

To install gcc and openssl, use yum:

 sudo yum install gcc-c++ openssl-devel 

To install node -gyp (globally), use npm:

 npm install -g node-gyp 

Then npm bcrypt installation worked fine on centos

+6
source share

All Articles