Node.bcrypt.js: node-gyp rebuild fails on OS X 10.10.5

Created on 3 Nov 2015  ยท  7Comments  ยท  Source: kelektiv/node.bcrypt.js

When running npm update in this particular fork of Drywall, it fails with the following exception:

> [email protected] install /Users/bitbear/Dev.local/Drywall/node_modules/bcrypt
> node-gyp rebuild

  CXX(target) Release/obj.target/bcrypt_lib/src/blowfish.o
/Users/bitbear/Dev.local/Drywall/node_modules/.bin/touch: line 1: syntax error near unexpected token `('
/Users/bitbear/Dev.local/Drywall/node_modules/.bin/touch: line 1: `var touch = require("../touch")'
make: *** [Release/obj.target/bcrypt_lib/src/blowfish.o] Error 2
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/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 Darwin 14.5.0
gyp ERR! command "/usr/local/Cellar/node/5.0.0/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/bitbear/Dev.local/Drywall/node_modules/bcrypt
gyp ERR! node -v v5.0.0
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
npm ERR! Darwin 14.5.0
npm ERR! argv "/usr/local/Cellar/node/5.0.0/bin/node" "/usr/local/bin/npm" "update"
npm ERR! node v5.0.0
npm ERR! npm  v3.3.9
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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.

I've read every comment in #90, but neither of the suggestions help. After removing ~/.node-gyp, running this:

npm un bcrypt;npm i bcrypt --save;npm un node-gyp -g;npm i -g node-gyp && node-gyp clean

and everything else suggested there, npm install still fails. Any ideas what causes this and how I can fix it?

Most helpful comment

As I write in nodejs/node-gyp#795, I managed to solve the problem by installing the latest version of touch:

npm install touch@latest

This allowed me to (first unlink and then) npm install bcrypt successfully. Seems like the version of touch I had installed was 0.0.4 and that the missing shebang that caused everything to crash has been added in version 1.0.0.

All 7 comments

mine is the same to you

Same here.

Not likely an issue with this module. Likely node-gyp issue if anything. Most likely an issue with your environment or setup.

@defunctzombie I don't know, but shouldn't an issue with my environment or setup cause a download of the latest bcrypt release and doing npm install && make fail? However, it succeeds:

> [email protected] install /Users/bitbear/Downloads/node.bcrypt.js-0.8.5
> node-gyp rebuild

  CXX(target) Release/obj.target/bcrypt_lib/src/blowfish.o
  CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt.o
  CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt_node.o
  SOLINK_MODULE(target) Release/bcrypt_lib.node
node-gyp clean
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | x64
gyp info ok
node-gyp configure
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | x64
gyp info spawn python2
gyp info spawn args [ '/usr/local/lib/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/bitbear/Downloads/node.bcrypt.js-0.8.5/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/local/lib/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/bitbear/.node-gyp/5.0.0/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/Users/bitbear/.node-gyp/5.0.0',
gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/bitbear/Downloads/node.bcrypt.js-0.8.5',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.' ]
gyp info ok
node-gyp build
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | x64
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
  CXX(target) Release/obj.target/bcrypt_lib/src/blowfish.o
  CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt.o
  CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt_node.o
  SOLINK_MODULE(target) Release/bcrypt_lib.node
gyp info ok
npm install .

> [email protected] install /Users/bitbear/Downloads/node.bcrypt.js-0.8.5
> node-gyp rebuild

  CXX(target) Release/obj.target/bcrypt_lib/src/blowfish.o
  CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt.o
  CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt_node.o
  SOLINK_MODULE(target) Release/bcrypt_lib.node

async.js
โœ” test_salt_length
โœ” test_salt_only_cb
โœ” test_salt_rounds_is_string_number
โœ” test_salt_rounds_is_string_non_number
โœ” test_hash
โœ” test_hash_rounds
โœ” test_hash_empty_strings
โœ” test_hash_no_params
โœ” test_hash_one_param
โœ” test_hash_salt_validity
โœ” test_verify_salt
โœ” test_verify_salt_min_rounds
โœ” test_verify_salt_max_rounds
โœ” test_hash_compare
โœ” test_hash_compare_empty_strings
โœ” test_hash_compare_invalid_strings

repetitions.js
โœ” test_salt_length
โœ” test_hash_length
โœ” test_compare
โœ” test_hash_and_compare

sync.js
โœ” test_salt_length
โœ” test_salt_no_params
โœ” test_salt_rounds_is_string_number
โœ” test_salt_rounds_is_NaN
โœ” test_hash
โœ” test_hash_rounds
โœ” test_hash_empty_string
โœ” test_hash_pw_no_params
โœ” test_hash_pw_one_param
โœ” test_hash_pw_not_hash_str
โœ” test_hash_salt_validity
โœ” test_verify_salt
โœ” test_verify_salt_min_rounds
โœ” test_verify_salt_max_rounds
โœ” test_hash_compare
โœ” test_hash_compare_empty_strings
โœ” test_hash_compare_invalid_strings
โœ” test_getRounds

OK: 15054 assertions (6170ms)

I also find it weird that npm install -g bcrypt works, while npm install bcrypt fails. Because I'm able to install bcrypt globally, doing npm link bcrypt fixes the issue, but I still find it weird that I'm both able to build bcrypt and install it globally, but installing it in this particular project fails.

As I write in nodejs/node-gyp#795, I managed to solve the problem by installing the latest version of touch:

npm install touch@latest

This allowed me to (first unlink and then) npm install bcrypt successfully. Seems like the version of touch I had installed was 0.0.4 and that the missing shebang that caused everything to crash has been added in version 1.0.0.

Ran into this problem trying to install ref on RHEL 6.5 with Node 0.10 (for an older project) and @asbjornu 's solution to install the latest version of "touch" worked for me as well.

Interesting note: If I ran npm i for the entire project, the install fails when trying to install ref. Any subsequent attempts to run npm i ref would also fail. But, if I rm -Rf node_modules and then npm i ref, ref would install fine, but then npm i would still fail when attempting to install ref.

Was this page helpful?
0 / 5 - 0 ratings