node.bcrypt.js: Bcrypt not installing | Throwing 404 for the referred resource in npm

I am on CentOS Linux System v7.2, running Node v7.6.0 and NPM v4.4.4. I am trying to install Bcrypt using sudo npm install brcypt but on the step node-pre-gyp install --fallback-to-build is called, it throws:

node-pre-gyp ERR! Tried to download(404): https://github.com/kelektiv/node.bcrypt.js/releases/download/v1.0.2/bcrypt_lib-v1.0.2-node-v48-linux-x64.tar.gz Not even opening in browser, hence this release-resource is certainly not available. But it is defined in some of the code. Some help really appreciated. (Please find attached the screenshot)

screen shot 2017-03-20 at 2 29 36 pm

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 16
  • Comments: 20

Most upvoted comments

Just a note for anyone that reads the above. While bcryptjs has the same API surface on the JS side; it does not actually implement background work in the same way as the c++ bindings. The c++ bindings use a background thread pool while bcryptjs will block your main thread pool. This may have implications on your services so make sure you understand what you are doing and how it will impact your services before blindly switching dependencies.

I’m on arch linux, so I installed python2, g++, make and npm install bcrypt, but it still didn’t work (still got the same 404 error, so I’m not sure how that fixes the problem…), so I downgraded node.js to its LTS version and now it’s working. thank you 😃

@strugee This is not an error with the library, but rather node-gyp See https://github.com/nodejs/node-gyp/issues/454

gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/.node-gyp/6.10.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/lib/node_modules/pump.io/node_modules/bcrypt/.node-gyp"

This happens if your script is executing at root. npm refuses to run as root and performs actions as the nobody user. As per @karimcitoh’s report above:

export USER=root
export HOME=/tmp

npm install --unsafe-perm

I have all the necessary dependancies.

Funny thing, cloning repository, checking v1.0.2 and building works perfectly:

Cloning into 'node.bcrypt.js'...
Note: checking out 'v1.0.2'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b new_branch_name

HEAD is now at 9036615... v1.0.2
bcrypt@1.0.2 /artifacts/formide-client/node.bcrypt.js
`-- nan@2.5.0 

node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using node-pre-gyp@0.6.34
node-pre-gyp info using node@4.6.0 | linux | arm
gyp info it worked if it ends with ok
gyp info using node-gyp@3.6.0
gyp info using node@4.6.0 | linux | arm
gyp info ok 
gyp info it worked if it ends with ok
gyp info using node-gyp@3.6.0
gyp info using node@4.6.0 | linux | arm
gyp http GET https://nodejs.org/download/release/v4.6.0/node-v4.6.0-headers.tar.gz
gyp http 200 https://nodejs.org/download/release/v4.6.0/node-v4.6.0-headers.tar.gz
gyp http GET https://nodejs.org/download/release/v4.6.0/SHASUMS256.txt
gyp http 200 https://nodejs.org/download/release/v4.6.0/SHASUMS256.txt
gyp info spawn /usr/bin/python2
gyp info spawn args [ '/opt/node/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   '/artifacts/formide-client/node.bcrypt.js/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/opt/node/lib/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/root/.node-gyp/4.6.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=/root/.node-gyp/4.6.0',
gyp info spawn args   '-Dnode_gyp_dir=/opt/node/lib/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=node.lib',
gyp info spawn args   '-Dmodule_root_dir=/artifacts/formide-client/node.bcrypt.js',
gyp info spawn args   '-Dnode_engine=v8',
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 
gyp info it worked if it ends with ok
gyp info using node-gyp@3.6.0
gyp info using node@4.6.0 | linux | arm
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory '/artifacts/formide-client/node.bcrypt.js/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/obj.target/bcrypt_lib.node
  COPY Release/bcrypt_lib.node
  COPY /artifacts/formide-client/node.bcrypt.js/lib/binding/bcrypt_lib.node
  TOUCH Release/obj.target/action_after_build.stamp
make: Leaving directory '/artifacts/formide-client/node.bcrypt.js/build'
gyp info ok 
node-pre-gyp info ok 

But npm install bcrypt@^1.0.2 doesn’t seem to work:

> bcrypt@1.0.2 install /artifacts/formide-client/node_modules/bcrypt
> node-pre-gyp install --fallback-to-build

node-pre-gyp ERR! Tried to download(404): https://github.com/kelektiv/node.bcrypt.js/releases/download/v1.0.2/bcrypt_lib-v1.0.2-node-v46-linux-arm.tar.gz 
node-pre-gyp ERR! Pre-built binaries not found for bcrypt@1.0.2 and node@4.6.0 (node-v46 ABI) (falling back to source compile with node-gyp) 
gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/.node-gyp/4.6.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/artifacts/formide-client/node_modules/bcrypt/.node-gyp"
make: *** No rule to make target '../.node-gyp/4.6.0/include/node/common.gypi', needed by 'Makefile'.  Stop.
make: Entering directory '/artifacts/formide-client/node_modules/bcrypt/build'
make: Leaving directory '/artifacts/formide-client/node_modules/bcrypt/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/opt/node/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276: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 Linux 4.8.3-std-1
gyp ERR! command "/opt/node/bin/node" "/opt/node/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/artifacts/formide-client/node_modules/bcrypt/lib/binding/bcrypt_lib.node" "--module_name=bcrypt_lib" "--module_path=/artifacts/formide-client/node_modules/bcrypt/lib/binding"
gyp ERR! cwd /artifacts/formide-client/node_modules/bcrypt
gyp ERR! node -v v4.6.0
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok 
node-pre-gyp ERR! build error 
node-pre-gyp ERR! stack Error: Failed to execute '/opt/node/bin/node /opt/node/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/artifacts/formide-client/node_modules/bcrypt/lib/binding/bcrypt_lib.node --module_name=bcrypt_lib --module_path=/artifacts/formide-client/node_modules/bcrypt/lib/binding' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/artifacts/formide-client/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at emitTwo (events.js:87:13)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:829:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
node-pre-gyp ERR! System Linux 4.8.3-std-1
node-pre-gyp ERR! command "/opt/node/bin/node" "/artifacts/formide-client/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /artifacts/formide-client/node_modules/bcrypt
node-pre-gyp ERR! node -v v4.6.0
node-pre-gyp ERR! node-pre-gyp -v v0.6.32
node-pre-gyp ERR! not ok 
Failed to execute '/opt/node/bin/node /opt/node/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/artifacts/formide-client/node_modules/bcrypt/lib/binding/bcrypt_lib.node --module_name=bcrypt_lib --module_path=/artifacts/formide-client/node_modules/bcrypt/lib/binding' (1)