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

Created on 20 Mar 2017  Â·  20Comments  Â·  Source: kelektiv/node.bcrypt.js

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

Most helpful comment

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.

All 20 comments

you have read the issue #476 ?

@akigupta131 Did you find a solution for this? I have exactly the same error. And it only happens to me in Docker.

make: Entering directory '/artifacts/client/node_modules/bcrypt/build'
make: Leaving directory '/artifacts/client/node_modules/bcrypt/build'
make: *** No rule to make target '../.node-gyp/4.6.0/include/node/common.gypi', needed by 'Makefile'.  Stop.
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)

@karimcitoh you need to add g++ and make packges in your Dockerfile. Add appropriate RUN commands as per the base image. Check this page for setup instructions: https://nodejs.org/en/download/package-manager

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
[email protected] /artifacts/formide-client/node.bcrypt.js
`-- [email protected] 

node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using [email protected]
node-pre-gyp info using [email protected] | linux | arm
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | linux | arm
gyp info ok 
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | 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 [email protected]
gyp info using [email protected] | 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:

> [email protected] 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 [email protected] and [email protected] (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)

This worked for me!

export USER=root
export HOME=/tmp

@karimcitoh gyp refuses to run as root. I tried installing as root and got the same error. Try adding a user and using a USER instruction and switching to it before performing a npm install. See
https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/#user

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-v51-linux-x64.tar.gz

Build version 1.0.2 don't contain linux platform

@cakiem8x We are aware of the issue. See this page for installing compile time dependencies to install bcrypt in linux: https://github.com/kelektiv/node.bcrypt.js/wiki/Installation-Instructions

@defunctzombie Please upload linux binaries when you get time, as a temporary measure. See #483 on how to fetch them.

This missing release is the reason our deploys had to build bcrypt during installation, which in turn failed because of the downtime in nodejs.org (installation requires downloading some headers).

@brocoli The download of headers is a one time affair.

I have a user who reported this error on a regular Debian system; also on Node 6. Older bcrypt installs have worked for him in the past. Pretty sure he has make and g++ installed, but I'll double-check.

See pump-io/pump.io#1333 for logs.

I can confirm that this user has the entire build-essential package installed from Debian, including Make and g++.

@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

Ah, gotcha. :/ that's unfortunate.

Thanks and sorry for the noise; this really seemed like a bcrypt issue since it used to work.

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.

Is there a way to change the directory in which npm is trying to download from? This link https://github.com/kelektiv/node.bcrypt.js/releases/download/v2.0.1/bcrypt_lib-v2.0.1-node-v46-linux-x64-glibc.tar.gz works (it has v46 instead of v64...) where with the default link I get a 404 error.

No that is working as intended.

v64 is node 10, that only works when doing a source compile ATM. There were
some problems building the binary on Travis after the upgrade.

For now, install python2, g++, make and npm install bcrypt. See the
installation instructions for a proper documentation.

On Wed, May 2, 2018 at 1:55 PM Roee Shapira notifications@github.com
wrote:

Is there a way to change the directory in which npm is trying to download
from? This link
https://github.com/kelektiv/node.bcrypt.js/releases/download/v2.0.1/bcrypt_lib-v2.0.1-node-v46-linux-x64-glibc.tar.gz
works (it has v46 instead of v64...) where with the default link I
get a 404 error.

—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
https://github.com/kelektiv/node.bcrypt.js/issues/500#issuecomment-385901842,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AQCaTwvY-a0H0v8qqaFUmecdLav_iOq3ks5tuW1rgaJpZM4MiKpA
.

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 :)

Was this page helpful?
0 / 5 - 0 ratings