无法在EC2上使用npm安装bcrypt

Buz*_*zut 5 amazon-ec2 amazon-web-services node.js npm

在Amazon EC2实例上的Ubuntu Server 14.04上,我在执行操作时出错npm install.它无法安装bcrypt("bcrypt": "^0.8.1"在我的package.json).

这是我的错误:

> bcrypt@0.8.1 install /home/ubuntu/app/node_modules/bcrypt
> node-gyp rebuild

child_process: customFds option is deprecated, use stdio instead.
make: Entering directory `/home/ubuntu/app/node_modules/bcrypt/build'
  CXX(target) Release/obj.target/bcrypt_lib/src/blowfish.o
make: g++: Command not found
make: *** [Release/obj.target/bcrypt_lib/src/blowfish.o] Error 127
make: Leaving directory `/home/ubuntu/app/node_modules/bcrypt/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/home/ubuntu/node-v0.12.0-linux-x64/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1067:12)
gyp ERR! System Linux 3.13.0-44-generic
gyp ERR! command "node" "/home/ubuntu/node-v0.12.0-linux-x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/ubuntu/app/node_modules/bcrypt
gyp ERR! node -v v0.12.0
gyp ERR! node-gyp -v v1.0.2
gyp ERR! not ok 
Run Code Online (Sandbox Code Playgroud)

Buz*_*zut 3

我只需要安装构建工具sudo apt-get install build-essential g++

\n\n

请注意,您必须apt-get update避免 EC2 上的 apt-get 出现任何问题(否则您最终可能会遇到E: Failed to fetch\xe2\x80\xa6

\n\n

然后npm install再一次,你就可以出发了!

\n