2014-02-12 121 views
5

我试图在Ubuntu中安装bcrypt,但出现以下错误。我无法正确理解错误消息。下面是关于同一问题的一些讨论:https://github.com/ncb000gt/node.bcrypt.js/issues/90但仍未找到解决方案。bcrypt未在Ubuntu上安装

我也尝试更新npm(npm install -g npm)和安装bcrypt没有运气。

[email protected]:~/Documents/xpressnepal$ sudo npm install 
npm http GET https://registry.npmjs.org/bcrypt/0.7.7 
npm http 304 https://registry.npmjs.org/bcrypt/0.7.7 
npm http GET https://registry.npmjs.org/bindings/1.0.0 
npm http 304 https://registry.npmjs.org/bindings/1.0.0 

> [email protected] install /home/isha/Documents/xpressnepal/node_modules/bcrypt 
> node-gyp rebuild 

gyp ERR! configure error 
gyp ERR! stack Error: "pre" versions of node cannot be installed, use the --nodedir flag instead 
gyp ERR! stack  at install (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/install.js:65:16) 
gyp ERR! stack  at Object.self.commands.(anonymous function) [as install] (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/node-gyp.js:66:37) 
gyp ERR! stack  at getNodeDir (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:150:20) 
gyp ERR! stack  at /usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:93:9 
gyp ERR! stack  at ChildProcess.exithandler (child_process.js:694:7) 
gyp ERR! stack  at ChildProcess.EventEmitter.emit (events.js:107:17) 
gyp ERR! stack  at maybeClose (child_process.js:817:16) 
gyp ERR! stack  at Process.ChildProcess._handle.onexit (child_process.js:884:5) 
gyp ERR! System Linux 3.8.0-19-generic 
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" 
gyp ERR! cwd /home/isha/Documents/xpressnepal/node_modules/bcrypt 
gyp ERR! node -v v0.11.11-pre 
gyp ERR! node-gyp -v v0.12.2 
gyp ERR! not ok 
npm ERR! [email protected] install: `node-gyp rebuild` 
npm ERR! Exit status 1 
npm ERR! 
npm ERR! Failed at the [email protected] install script. 
npm ERR! 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-gyp rebuild 
npm ERR! You can get their info via: 
npm ERR!  npm owner ls bcrypt 
npm ERR! There is likely additional logging output above. 

npm ERR! System Linux 3.8.0-19-generic 
npm ERR! command "node" "/usr/local/bin/npm" "install" 
npm ERR! cwd /home/isha/Documents/xpressnepal 
npm ERR! node -v v0.11.11-pre 
npm ERR! npm -v 1.3.26 
npm ERR! code ELIFECYCLE 
npm ERR! 
npm ERR! Additional logging details can be found in: 
npm ERR!  /home/isha/Documents/xpressnepal/npm-debug.log 
npm ERR! not ok code 0 
[email protected]:~/Documents/xpressnepal$ 
+1

是你有可能使用Node.js的更“稳定”的版本?您可能还想尝试在本地而不是全局安装'bcrypt'软件包。你可能会错过一些'bcrypt'需要的库。看看http://stackoverflow.com/a/20895568/732396 – yanhan

+0

@yanhan非常感谢,我在安装稳定版本的节点后按照您的建议摆脱了这个问题。 – Isha

+0

很高兴知道您已解决您的问题。我已经添加了我的评论作为答案;如果你足够给我答案,我提前感谢你 – yanhan

回答

4

使用最新的稳定版本的node.js. bcrypt尚未被移植到节点0.11.x.

如果您使用的是git的克隆,只要进入到树和结账0.10.26释放:

git checkout v0.10.26-release 
fetch 

然后,配置,制造,安装和往常一样。然后尝试再次安装bcrypt:

npm install -g bcrypt 

信贷去延安。他指出我正确的方向。我只想发布可修复它的特定命令。

+0

我有使用Node v0.10.28的同样的问题。使用NVM切换到v0.10.26并且bcrypt安装顺利。 – godfrzero

0

更改你0.11.x节点版本0.10.xbcrypt没有移植到0.11.x.

,如果你有Ñ(节点版本管理器)安装然后运行:

Ñ0.10.x
(例如,x = 26或x = 24等等)

然后运行:

NPM安装bcrypt

插件理解你的项目目录。 要安装ň运行

NPM安装ñ