' npm install bcrypt'在Ubuntu 17.04 64位上失败

时间:2017-06-09 11:20:43

标签: javascript node.js ubuntu npm bcrypt

我正在尝试将bcrypt安装为节点依赖项:

https://www.npmjs.com/package/bcrypt

我的环境:

  • Ubuntu 17.04,64位
  • node v6.11.0
  • npm v4.2.0

我已按照Ubuntu的说明进行操作:

https://github.com/kelektiv/node.bcrypt.js/wiki/Installation-Instructions#ubuntu-and-derivatives---elementary-linux-mint-etc

安装似乎挂在node-pre-gyp build上。

堆栈跟踪:

$ npm install bcrypt

    bcrypt@1.0.2 install /XXXXXX/node_modules/bcrypt
    node-pre-gyp install --fallback-to-build

module.js:472
throw err;
^

Error: Cannot find module './internal/streams/stream'
at Function.Module._resolveFilename (module.js:470:15)
at Function.Module._load (module.js:418:25)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object. (/XXXXXXXX/node_modules/readable-stream/lib/_stream_readable.js:28:14)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! Linux 4.10.0-19-generic
npm ERR! argv "/XXXX/.nvm/versions/node/v7.10.0/bin/node" "/XXXX/.nvm/versions/node/v7.10.0/bin/npm" "install" "bcrypt"
npm ERR! node v6.11.0
npm ERR! npm v4.2.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1

npm ERR! bcrypt@1.0.2 install: node-pre-gyp install --fallback-to-build
npm ERR! Exit status 1

有趣的是,我可以使用npm安装node-pre-gyp,但是node-pre-gyp install --fallback-to-build仍然会失败。

有什么建议吗?

2 个答案:

答案 0 :(得分:1)

使用bcrypt模块而不是`npm install bcrypt-nodejs`

 var bcrypt  = require('bcrypt-nodejs');

然后

var xml = (new DOMParser()).parseFromString($('#textarea').val(), 'text/xml')

答案 1 :(得分:0)

在GitHub问题线程中解决: https://github.com/kelektiv/node.bcrypt.js/issues/514

需要g ++编译器:

  

sudo apt-get install build-essential g ++