profile
viewpoint

Ask questionsBcrypt failed to install via npm or yarn

Everything was working fine until i just update my windows 10 ( 1903 Latest), and just reconfigure my laptop for development, after cloning from git-hub, I was unable to run my nodejs express app due to Bcrypt. I've tried couple of attempts to install bcrypt via npm or yarn but failed. currently I'm at 3.0.4.

node version 12.4.0 npm version 6.9.0 python version 2.7 node-gyp version 3.8.0 node-pre-gyp version 0.12.0

error looks something like this.

C:\Users\asmat\Documents\SMARTOLLDB>npm install bcrypt@3.0.4

bcrypt@3.0.4 install C:\Users\asmat\Documents\SMARTOLLDB\node_modules\bcrypt node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Using needle for node-pre-gyp https download node-pre-gyp WARN Tried to download(404): https://github.com/kelektiv/node.bcrypt.js/releases/download/v3.0.4/bcrypt_lib-v3.0.4-node-v72-win32-x64-unknown.tar.gz node-pre-gyp WARN Pre-built binaries not found for bcrypt@3.0.4 and node@12.4.0 (node->v72 ABI, unknown) (falling back to source compile with node-gyp) Warning: unrecognized setting VCCLCompilerTool/MultiProcessorCompilation Warning: unrecognized setting VCCLCompilerTool/MultiProcessorCompilation Warning: unrecognized setting VCCLCompilerTool/MultiProcessorCompilation Warning: unrecognized setting VCCLCompilerTool/MultiProcessorCompilation Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch. MSBUILD : error MSB4132: The tools version "2.0" is unrecognized. Available tools versions are "4.0". gyp ERR! build error gyp ERR! stack Error: C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe failed with exit code: 1 gyp ERR! stack at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:262:23) gyp ERR! stack at ChildProcess.emit (events.js:200:13) gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12) gyp ERR! System Windows_NT 10.0.18362 gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "build" "--fallback-to-build" "--module=C:\U sers\asmat\Documents\SMARTOLLDB\node_modules\bcrypt\lib\binding\bcrypt_lib.node" "--module_name=bcrypt_lib" "--module_path=C:\Users\asmat\Documents\SMARTOLLDB\node_modules\bcr ypt\lib\binding" "--napi_version=4" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v72" gyp ERR! cwd C:\Users\asmat\Documents\SMARTOLLDB\node_modules\bcrypt gyp ERR! node -v v12.4.0 gyp ERR! node-gyp -v v3.8.0 gyp ERR! not ok node-pre-gyp ERR! build error node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build - -module=C:\Users\asmat\Documents\SMARTOLLDB\node_modules\bcrypt\lib\binding\bcrypt_lib.node --module_name=bcrypt_lib --module_path=C:\Users\asmat\Documents\SMARTOLLDB\node_modules\bcrypt\li b\binding --napi_version=4 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72' (1) node-pre-gyp ERR! stack at ChildProcess.<anonymous> (C:\Users\asmat\Documents\SMARTOLLDB\node_modules\bcrypt\node_modules\node-pre-gyp\lib\util\compile.js:83:29) node-pre-gyp ERR! stack at ChildProcess.emit (events.js:200:13) node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:1021:16) node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5) node-pre-gyp ERR! System Windows_NT 10.0.18362 node-pre-gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\asmat\Documents\SMARTOLLDB\node_modules\bcrypt\node_modules\node-pre-gyp\bin\node-pre-gyp" "install" "--f allback-to-build" node-pre-gyp ERR! cwd C:\Users\asmat\Documents\SMARTOLLDB\node_modules\bcrypt node-pre-gyp ERR! node -v v12.4.0 node-pre-gyp ERR! node-pre-gyp -v v0.12.0 node-pre-gyp ERR! not ok Failed to execute 'C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --module=C:\Users\asmat\Document s\SMARTOLLDB\node_modules\bcrypt\lib\binding\bcrypt_lib.node --module_name=bcrypt_lib --module_path=C:\Users\asmat\Documents\SMARTOLLDB\node_modules\bcrypt\lib\binding --napi_version=4 --no de_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72' (1) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! bcrypt@3.0.4 install: node-pre-gyp install --fallback-to-build npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the bcrypt@3.0.4 install script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\asmat\AppData\Roaming\npm-cache_logs\2019-06-21T00_22_51_046Z-debug.log `

kelektiv/node.bcrypt.js

Answer questions DerMika

I got the same issue when building our application's Dockerfile.

We're using Alpine, I had to change the following line:

RUN apk add --no-cache make gcc g++ python && \
  npm install

to

RUN apk --no-cache add --virtual builds-deps build-base python && \
  npm install

As mentioned in the Wiki: https://github.com/kelektiv/node.bcrypt.js/wiki/Installation-Instructions#alpine-linux-based-images

I don't know when this changed, and it used to work until very recently, but this was the fix for us.

useful!
source:https://uonfu.com/
Github User Rank List