npm install bcrypt在node-gyp rebuild中失败

时间:2015-11-12 10:10:12

标签: node.js npm

我正在尝试安装节点模块bcrypt

所以我运行了以下命令

sudo npm install bcrypt

有了这个我得到以下错误:

gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:270:23)
gyp ERR! stack     at emitTwo (events.js:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Linux 3.19.0-25-generic
gyp ERR! command "/usr/bin/nodejs" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /var/www/learningbankapi/src/node_modules/bcrypt
gyp ERR! node -v v4.2.2
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok 
npm ERR! Linux 3.19.0-25-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "bcrypt"
npm ERR! node v4.2.2
npm ERR! npm  v2.14.7
npm ERR! code ELIFECYCLE

npm ERR! bcrypt@0.8.1 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the bcrypt@0.8.1 install script 'node-gyp rebuild'.
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! Please include the following file with any support request:
npm ERR!     /var/www/learningbankapi/src/npm-debug.log

我试图删除所有模块,sudo npm install我也试图重建但没有结果可以帮助我吗?

2 个答案:

答案 0 :(得分:3)

只需安装build-essential软件包:

sudo apt install build-essential

并安装bcrypt:

npm i -S bcrypt

答案 1 :(得分:0)

在谷歌搜索了一个小时后,我做了以下3件事,并在最后一件事之后开始工作。我知道你不在Windows上,但也许来到这里的其他人会像我一样在Windows机器上看到这个。

1。)我确保将Python下载到C:\ Python2.7并设置了Python的路径变量。

2。)我做了

npm install --global --production windows-build-tools`

它实际上只通过这篇文章的Python部分,下一次安装(无论它可能是什么,我不知道,因为花了太长时间)说它安装了一个小时,所以我就停止了它转到第3步。幸好它有效。

3.)我将下面的内容添加到我的package.json中,如另一个github线程所示。在这样做之后,确保PYTHON变量是正确的,它开始工作。  ```

"env": {
    "PYTHON": "C:/python2.7"
  },
  "subdomain": "bcrypt-test",
  "engines": {
    "node": "0.6.x"
  },
  "repository": {},
  "domains": [],
  "databases": {}
}