无法在Centos Server上安装bcrypt node.js模块

我试图在CentOS服务器上安装bcrypt,但是我得到以下错误:

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 {} 

我能做些什么来解决这个问题? 谢谢,

我得到了相同的问题做npm安装bcrypt。 另一种select是从源代码安装。

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

将node.bcrypt.js文件夹重命名为bcrypt,并将其移动到您的项目的node_modules中。

您可以通过执行npm install -g node-gyp(-g全局安装)来安装node-gyp。

还有一个native-js版本的bcrypt,不需要编译。 https://github.com/shaneGirish/bcrypt-nodejs

 npm install bcrypt-nodejs 

api与编译版本非常相似。 以下内容直接从自述中获取

基本用法:

同步

 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 }); 

对我来说,答案是确保我已经安装了gcc,openssl和node-gyp。

要安装gcc和openssl,请使用yum:

 sudo yum install gcc-c++ openssl-devel 

要安装node-gyp(全局),请使用npm:

 npm install -g node-gyp 

然后bcrypt的npm安装在centos上工作得很好