Linux上的Bcrypt安装失败

时间:2015-11-29 21:07:36

标签: node.js ubuntu npm bcrypt

首先,我尝试使用npm安装bcrypt。

错误:

/
> bcrypt@0.8.5 install /home/saaggy18/node-projects/10-projects/node_modules/bcrypt
> node-gyp rebuild

/usr/local/lib/node_modules/npm/bin/node-gyp-bin/node-gyp: 3: /usr/local/lib/node_modules/npm/bin/node-gyp-bin/node-gyp: node: Permission denied
npm ERR! Linux 3.19.0-33-generic
npm ERR! argv "/usr/local/bin/node" "/usr/local/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.5 install: `node-gyp rebuild`
npm ERR! Exit status 126
npm ERR! 
npm ERR! Failed at the bcrypt@0.8.5 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!     /home/saaggy18/node-projects/10-projects/npm-debug.log

然后我找到了this问题

在第3步,即node-gyp configure

这是一个错误:

Error: Cannot find module 'nan'
    at Function.Module._resolveFilename (module.js:337:15)
    at Function.Module._load (module.js:287:25)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at [eval]:1:1
    at Object.exports.runInThisContext (vm.js:54:17)
    at Object.<anonymous> ([eval]-wrapper:6:22)
    at Module._compile (module.js:435:26)
    at node.js:578:27
    at doNTCallback0 (node.js:419:9)
gyp: Call to 'node -e "require('nan')"' returned exit status 1 while in binding.gyp. while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/node-gyp/lib/configure.js:305:16)
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-33-generic
gyp ERR! command "/usr/local/bin/node" "/usr/local/bin/node-gyp" "configure"
gyp ERR! cwd /home/saaggy18/node.bcrypt.js
gyp ERR! node -v v4.2.2
gyp ERR! node-gyp -v v3.2.0
gyp ERR! not ok 

我的操作系统:小学Os Freya,基本上是Ubuntu和 我安装了python。

2 个答案:

答案 0 :(得分:3)

尝试使用以下命令安装build-essential:

  

sudo apt-get install build-essential

然后再试一次。我希望这会对你有所帮助

答案 1 :(得分:0)

我建议使用nvm安装节点,以免让自己为此感到头疼。