bcrypt没有在ubuntu上安装

时间:2014-02-12 08:02:58

标签: node.js npm bcrypt

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

我还尝试更新npm(npm install -g npm)并安装bcrypt而没有运气。

isha@isha-ubuntu:~/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

> bcrypt@0.7.7 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! bcrypt@0.7.7 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the bcrypt@0.7.7 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
isha@isha-ubuntu:~/Documents/xpressnepal$ 

5 个答案:

答案 0 :(得分:4)

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

如果您使用的是git clone,只需cd进入树并结帐0.10.26-release:

git checkout v0.10.26-release
fetch

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

npm install -g bcrypt

归功于yanhan。他指出了我正确的方向。我只想发布修复它的具体命令。

答案 1 :(得分:1)

您可能希望尝试使用更稳定版本的node.js安装bcrypt。您可能还缺少bcrypt所需的某些库,请参阅https://stackoverflow.com/a/20895568/732396

答案 2 :(得分:0)

由于 bcrypt 未移植到 0.11.x. < /强>

如果您安装了 n (节点版本管理器),请运行:

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

然后运行:

npm install bcrypt

在项目目录中。 要安装 n 运行

npm install n

答案 3 :(得分:0)

我有同样的问题,但我已解决

我用它代替了npm纱线

yarn是npm之类的软件包管理器

首先安装yarn您的系统,然后使用此命令安装bcrypt

  

yarn add bcrypt

答案 4 :(得分:0)

在ubuntu当前版本上安装bcrypt 加密 需要安装-> node-pre-gyp

安装后需要安装

尝试cmd-> sudo npm install bcrypt