Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Impossible to install bcrypt with npm on EC2

On an Ubuntu Server 14.04 on an Amazon EC2 instance, I had an error when doing npm install. It failed to install bcrypt ("bcrypt": "^0.8.1"in my package.json).

Here's the error I had:

> [email protected] 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 
like image 693
Buzut Avatar asked Mar 17 '15 15:03

Buzut


2 Answers

I just had to install the build tools sudo apt-get install build-essential g++

Note that you have to apt-get update to avoid any problem with apt-get on EC2 (otherwise you might end up with E: Failed to fetch…

Then npm install again and you're good to go!

like image 80
Buzut Avatar answered Nov 04 '22 16:11

Buzut


Fixed by installing and compiling with gcc 4.4 like this:

yum install gcc44 gcc44-c++
export CC="gcc44"
export CXX="g++44"
npm install -g level

reference: Level/levelup#224

like image 34
Du Luong Avatar answered Nov 04 '22 14:11

Du Luong