Skip to content

Bcrypt not installing | Throwing 404 for the referred resource in npm #500

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
akashdeepsinghal opened this issue Mar 20, 2017 · 20 comments
Closed

Comments

@akashdeepsinghal
Copy link

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

@antwal
Copy link

antwal commented Mar 21, 2017

you have read the issue #476 ?

@karimcitoh
Copy link

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

@karimcitoh
Copy link

karimcitoh commented Mar 22, 2017

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)

@recrsn
Copy link
Collaborator

recrsn commented Mar 22, 2017

@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

@recrsn
Copy link
Collaborator

recrsn commented Mar 22, 2017

@karimcitoh
Copy link

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)

@karimcitoh
Copy link

This worked for me!

export USER=root
export HOME=/tmp

@recrsn
Copy link
Collaborator

recrsn commented Mar 22, 2017

@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

@cakiem8x
Copy link

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

@recrsn
Copy link
Collaborator

recrsn commented Mar 27, 2017

@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.

@brocoli
Copy link

brocoli commented Apr 5, 2017

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

@recrsn
Copy link
Collaborator

recrsn commented Apr 5, 2017

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

@strugee
Copy link

strugee commented Apr 14, 2017

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.

@strugee
Copy link

strugee commented Apr 14, 2017

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

@recrsn
Copy link
Collaborator

recrsn commented Apr 14, 2017

@strugee This is not an error with the library, but rather node-gyp See nodejs/node-gyp#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

@strugee
Copy link

strugee commented Apr 14, 2017

Ah, gotcha. :/ that's unfortunate.

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

@recrsn recrsn closed this as completed Jul 7, 2017
@defunctzombie
Copy link
Collaborator

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.

@5c077m4n
Copy link

5c077m4n commented May 2, 2018

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.

@recrsn
Copy link
Collaborator

recrsn commented May 2, 2018 via email

@5c077m4n
Copy link

5c077m4n commented May 2, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants