5

I tried to install bcrypt in Ubuntu but got following error. I can't understand error message properly. Here is some discussion regarding to the same problem : https://github.com/ncb000gt/node.bcrypt.js/issues/90 but still no solution found.

I have also tried to update npm(npm install -g npm) and installing the bcrypt with no luck.

isha@isha-ubuntu:~/Documents/xpressnepal$ sudo npm install
npm http GET https://registry.npmjs.org/bcrypt/0.7.7
npm http 304 https://registry.npmjs.org/bcrypt/0.7.7
npm http GET https://registry.npmjs.org/bindings/1.0.0
npm http 304 https://registry.npmjs.org/bindings/1.0.0

> bcrypt@0.7.7 install /home/isha/Documents/xpressnepal/node_modules/bcrypt
> node-gyp rebuild

gyp ERR! configure error 
gyp ERR! stack Error: "pre" versions of node cannot be installed, use the --nodedir flag instead
gyp ERR! stack     at install (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/install.js:65:16)
gyp ERR! stack     at Object.self.commands.(anonymous function) [as install] (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/node-gyp.js:66:37)
gyp ERR! stack     at getNodeDir (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:150:20)
gyp ERR! stack     at /usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:93:9
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:694:7)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:107:17)
gyp ERR! stack     at maybeClose (child_process.js:817:16)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:884:5)
gyp ERR! System Linux 3.8.0-19-generic
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/isha/Documents/xpressnepal/node_modules/bcrypt
gyp ERR! node -v v0.11.11-pre
gyp ERR! node-gyp -v v0.12.2
gyp ERR! not ok 
npm ERR! bcrypt@0.7.7 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the bcrypt@0.7.7 install script.
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! System Linux 3.8.0-19-generic
npm ERR! command "node" "/usr/local/bin/npm" "install"
npm ERR! cwd /home/isha/Documents/xpressnepal
npm ERR! node -v v0.11.11-pre
npm ERR! npm -v 1.3.26
npm ERR! code ELIFECYCLE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/isha/Documents/xpressnepal/npm-debug.log
npm ERR! not ok code 0
isha@isha-ubuntu:~/Documents/xpressnepal$ 
Isha
  • 61
  • 1
  • 1
  • 3
  • 1
    is it possible for you to use a more 'stable' version of node.js ? You might also want to try installing the `bcrypt` package locally instead of globally. It might be possible that you are missing some libraries that `bcrypt` requires. Check out http://stackoverflow.com/a/20895568/732396 – yanhan Feb 12 '14 at 10:04
  • @yanhan thanks a lot , I get rid of this problem after installing the stable version of node as you suggested. – Isha Feb 12 '14 at 11:50
  • good to know you've solved your problem. I've added my comment as an answer; if you're kind enough to award me the answer, I thank you in advance – yanhan Feb 12 '14 at 13:10
  • Updating npm helped me solve this issue `sudo npm update -g npm` – Jonathan Maim Jul 14 '14 at 10:40

6 Answers6

4

Use the latest stable version of node.js. bcrypt hasn't been ported to node 0.11.x.

If you are using a git clone, simply cd into the tree and checkout 0.10.26-release:

git checkout v0.10.26-release
fetch

Then configure, make, and install as usual. Then try installing bcrypt again:

npm install -g bcrypt

Credit goes to yanhan. He pointed me in the right direction. I just wanted to post the specific commands that would fix it.

JoeAndrieu
  • 804
  • 6
  • 6
  • I had the same problem using Node v0.10.28. Used NVM to switch to v0.10.26 and bcrypt installed without a hitch. – godfrzero May 14 '14 at 13:24
1

i have same problem but i fixed it

i used instead of npm yarn

yarn is package manager like npm

first install yarn your system then use this command to install bcrypt

yarn add bcrypt

amein abdi
  • 11
  • 3
1

TO install bcrypt on ubuntu current version bcrypt required to install-> node-pre-gyp

after install installing required

try cmd->sudo npm install bcrypt

Nitish Kumar
  • 111
  • 3
0

You might want to try installing bcrypt with a more stable version of node.js . It might be also possible that you are missing some libraries that bcrypt requires, see https://stackoverflow.com/a/20895568/732396

Community
  • 1
  • 1
yanhan
  • 3,507
  • 3
  • 28
  • 38
0

Change you node version from 0.11.x to 0.10.x as bcrypt is not ported into 0.11.x.

if you have n (node version manager) installed then run:

n 0.10.x
(e.g x=26 or x=24 etc.)

Then run:

npm install bcrypt

inside your project directory. To install n run

npm install n

Abhishek Kaushik
  • 1,121
  • 1
  • 13
  • 17
0

I've had a similar problem. Nothing worked, but what managed to do the trick was installing bcryptjs instead of bcrypt.

bojkel
  • 63
  • 2
  • 10