node.bcrypt.js: Bcrypt fails to install on node v 8.12.0

What went wrong,

Installing bcrypt@3.0.0 on node v 8.12.0 causes an installation error where previous versions (8.11.4) did not. See snippet below for the install log

node-pre-gyp WARN Pre-built binaries not installable for bcrypt@3.0.0 and node@8.12.0 (node-v57 ABI, glibc) (falling back to source compile with node-gyp)
node-pre-gyp WARN Hit error Remote end closed socket abruptly.
make: Entering directory '/home/gerwinb/triply/triply-server/node_modules/bcrypt/build'
  CXX(target) Release/obj.target/bcrypt_lib/src/blowfish.o
  CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt.o
node-pre-gyp WARN Pre-built binaries not installable for bcrypt@3.0.0 and node@8.12.0 (node-v57 ABI, glibc) (falling back to source compile with node-gyp)
node-pre-gyp WARN Hit error bad download
../src/bcrypt.cc: In function ‘void encode_salt(char*, u_int8_t*, char, u_int16_t, u_int8_t)’:
../src/bcrypt.cc:114:1: warning: ‘__builtin___snprintf_chk’ output may be truncated before the last format character [-Wformat-truncation=]
 encode_salt(char *salt, u_int8_t *csalt, char minor, u_int16_t clen, u_int8_t logr)
 ^~~~~~~~~~~
In file included from /usr/include/stdio.h:862:0,
                 from ../src/bcrypt.cc:34:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:65:44: note: ‘__builtin___snprintf_chk’ output between 4 and 5 bytes into a destination of size 4
        __bos (__s), __fmt, __va_arg_pack ());
                                            ^
../src/bcrypt.cc: In function ‘void bcrypt(const char*, const char*, char*)’:
../src/bcrypt.cc:147:1: warning: ‘__builtin___snprintf_chk’ output may be truncated before the last format character [-Wformat-truncation=]
 bcrypt(const char *key, const char *salt, char *encrypted)
 ^~~~~~
In file included from /usr/include/stdio.h:862:0,
                 from ../src/bcrypt.cc:34:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:65:44: note: ‘__builtin___snprintf_chk’ output between 4 and 5 bytes into a destination of size 4
        __bos (__s), __fmt, __va_arg_pack ());
                                            ^
../src/bcrypt.cc: At global scope:
../src/bcrypt.cc:316:1: fatal error: opening dependency file ./Release/.deps/Release/obj.target/bcrypt_lib/src/bcrypt.o.d.raw: No such file or directory
 }
 ^
compilation terminated.
bcrypt_lib.target.mk:103: recipe for target 'Release/obj.target/bcrypt_lib/src/bcrypt.o' failed
make: *** [Release/obj.target/bcrypt_lib/src/bcrypt.o] Error 1
make: Leaving directory '/home/gerwinb/triply/triply-server/node_modules/bcrypt/build'
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:262:23)
gyp ERR! stack     at emitTwo (events.js:126:13)
gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Linux 4.15.0-34-generic
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/home/gerwinb/triply/triply-server/node_modules/bcrypt/lib/binding/bcrypt_lib.node" "--module_name=bcrypt_lib" "--module_path=/home/gerwinb/triply/triply-server/node_modules/bcrypt/lib/binding" "--napi_version=3" "--node_abi_napi=napi"
gyp ERR! cwd /home/gerwinb/triply/triply-server/node_modules/bcrypt
gyp ERR! node -v v8.12.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 '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/home/gerwinb/triply/triply-server/node_modules/bcrypt/lib/binding/bcrypt_lib.node --module_name=bcrypt_lib --module_path=/home/gerwinb/triply/triply-server/node_modules/bcrypt/lib/binding --napi_version=3 --node_abi_napi=napi' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/home/gerwinb/triply/triply-server/node_modules/bcrypt/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at emitTwo (events.js:126:13)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:915:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
node-pre-gyp ERR! System Linux 4.15.0-34-generic
node-pre-gyp ERR! command "/usr/local/bin/node" "/home/gerwinb/triply/triply-server/node_modules/bcrypt/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /home/gerwinb/triply/triply-server/node_modules/bcrypt
node-pre-gyp ERR! node -v v8.12.0
node-pre-gyp ERR! node-pre-gyp -v v0.10.2
node-pre-gyp ERR! not ok
Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/home/gerwinb/triply/triply-server/node_modules/bcrypt/lib/binding/bcrypt_lib.node --module_name=bcrypt_lib --module_path=/home/gerwinb/triply/triply-server/node_modules/bcrypt/lib/binding --napi_version=3 --node_abi_napi=napi' (1)
Traceback (most recent call last):fo lifecycle bcrypt@3.0.0~install: Failed to exec install script
  File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 16, in <module>
    sys.exit(gyp.script_main())
  File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 545, in script_main
    return main(sys.argv[1:])
  File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 538, in main
    return gyp_main(args)
  File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 502, in gyp_main
    'cwd': os.getcwd(),
OSError: [Errno 2] No such file or directory
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:345:16)
gyp ERR! stack     at emitTwo (events.js:126:13)
gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Linux 4.15.0-34-generic
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/home/gerwinb/triply/triply-server/node_modules/bcrypt/lib/binding/bcrypt_lib.node" "--module_name=bcrypt_lib" "--module_path=/home/gerwinb/triply/triply-server/node_modules/bcrypt/lib/binding" "--napi_version=3" "--node_abi_napi=napi"
gyp ERR! cwd /home/gerwinb/triply/triply-server/node_modules/bcrypt
gyp ERR! node -v v8.12.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm WARN ajv-keywords@3.2.0 requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN gulp-debug@4.0.0 requires a peer of gulp@>=4 but none is installed. You must install peer dependencies yourself.
npm WARN tslint-language-service@0.9.9 requires a peer of typescript@>= 2.3.1 < 3 but none is installed. You must install peer dependencies yourself.
npm WARN tslint-microsoft-contrib@5.1.0 requires a peer of typescript@^2.1.0 but none is installed. You must install peer dependencies yourself.
npm WARN @triply/triply-server@2.0.1 No license field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! bcrypt@3.0.0 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bcrypt@3.0.0 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!     /home/gerwinb/.npm/_logs/2018-09-14T12_06_58_533Z-debug.log

Which version and OS: Node version 1.12.0 OS: Ubuntu 18.04

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 59
  • Comments: 40

Commits related to this issue

Most upvoted comments

Please try with v3.0.1

This issue has normally been fix by this PR (https://github.com/kelektiv/node.bcrypt.js/pull/649) but the fix hasn’t been released on the npm repo yet. A release should be done soon with the fix but meanwhile you can link to the branch master of the github repo in your package.json like this :

"bcrypt": "https://github.com/kelektiv/node.bcrypt.js.git#master"

This is of course temporary solution.

We’re migrating to bcryptjs, zero dependencies, zero installation headaches.

With Node v8.X.X use bcrypt >= 1.0.3 and < 3.0.0 (source: front page)

I am also facing the same issue still with “bcrypt”: “3.0.1”, node 8.12.0 and npm 6.4.1 on Windows 10

I am still facing this issue on windows. Any update? I tried installing 3.0.1 version, still same error.

bcrypt@3.0.3 install C:\Users\Nduka Victor\Downloads\SecondApp-master\node_modules\bcrypt

node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Using request 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.3/bcrypt_lib-v3.0.3-node-v57-win32-x64-unknown.tar.gz node-pre-gyp WARN Pre-built binaries not found for bcrypt@3.0.3 and node@8.12.0 (node-v57 ABI, unknown) (falling back to source compile with node-gyp) Building the projects in this solution one at a time. To enable parallel build, please add the “/m” switch. MSBUILD : error MSB3428: Could not load the Visual C++ component “VCBuild.exe”. To fix this, 1) install the .NET Framework 2.0 SDK, 2) ins tall Microsoft Visual Studio 2005 or 3) add the location of the component to the system path if it is installed elsewhere. [C:\Users\Nduk a Victor\Downloads\SecondApp-master\node_modules\bcrypt\build\binding.sln] 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 emitTwo (events.js:126:13) gyp ERR! stack at ChildProcess.emit (events.js:214:7) gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12) gyp ERR! System Windows_NT 10.0.17134 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:\Users\Nduka Victor\Downloads\SecondApp-master\node_modules\bcrypt\lib\binding\bcrypt_lib.node” “–module_name=bcrypt_lib” “–module_path=C:\Users\Nduka Victor\Downloads\SecondApp-master\node_modules\bcrypt\lib\binding” “–napi_version=3” “–node_abi_napi=napi” “–napi_build_version=0” “–node_napi_label=node-v57” gyp ERR! cwd C:\Users\Nduka Victor\Downloads\SecondApp-master\node_modules\bcrypt gyp ERR! node -v v8.12.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\Nduka Victor\Downloads\SecondApp-master\node_modules\bcrypt\lib\binding\bcrypt_lib.node --module_name=bcrypt_lib --module_path=C:\Users\Nduka Victor\Downloads\SecondApp-master\node_modules\bcrypt\lib\binding --napi_version=3 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v57’ (1) node-pre-gyp ERR! stack at ChildProcess. (C:\Users\Nduka Victor\Downloads\SecondApp-master\node_modules\bcrypt\node_modules\node-pre-gyp\lib\util\compile.js:83:29) node-pre-gyp ERR! stack at emitTwo (events.js:126:13) node-pre-gyp ERR! stack at ChildProcess.emit (events.js:214:7) node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:915:16) node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5) node-pre-gyp ERR! System Windows_NT 10.0.17134 node-pre-gyp ERR! command “C:\Program Files\nodejs\node.exe” “C:\Users\Nduka Victor\Downloads\SecondApp-master\node_modules\bcrypt\node_modules\node-pre-gyp\bin\node-pre-gyp” “install” “–fallback-to-build” node-pre-gyp ERR! cwd C:\Users\Nduka Victor\Downloads\SecondApp-master\node_modules\bcrypt node-pre-gyp ERR! node -v v8.12.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\Nduka Victor\Downloads\SecondApp-master\node_modules\bcrypt\lib\binding\bcrypt_lib.node --module_name=bcrypt_lib --module_path=C:\Users\Nduka Victor\Downloads\SecondApp-master\node_modules\bcrypt\lib\binding --napi_version=3 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v57’ (1) npm WARN eslint-config-airbnb@15.0.1 requires a peer of eslint@^3.19.0 but none is installed. You must install peer dependencies yourself. npm WARN eslint-config-airbnb-base@11.3.2 requires a peer of eslint@^3.19.0 || ^4.5.0 but none is installed. You must install peer dependencies yourself. npm WARN eslint-plugin-jsx-a11y@5.1.1 requires a peer of eslint@^2.10.2 || ^3 || ^4 but none is installed. You must install peer dependencies yourself. npm WARN bookapi@1.0.0 No description npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.7: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“win32”,“arch”:“x64”})

npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! bcrypt@3.0.3 install: node-pre-gyp install --fallback-to-build npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the bcrypt@3.0.3 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\Nduka Victor\AppData\Roaming\npm-cache_logs\2019-01-20T10_21_54_399Z-debug.log PS C:\Users\Nduka Victor\Downloads\SecondApp-master>

Have you at any point installed bcrypt successfully before. If yes, then Try running yarn add bcrypt@3.0.2 or npm install --save bcrypt@3.0.2 . This works for me on node version 8.12.0

It seems that the main issue is node-pre-gyp which tries to use needle instead of request while downloading. needle is heavily broken.

However, I’m not able to reproduce the build failures. Source compile should always work if you have python2, make and a c++ compiler. The most likely reason is you are running npm as root (under sudo). Source compile will fail in such situations.

Manually adding request to dependencies causes node-pre-gyp to use it, which fixes issues associated with downloading pre-built binaries.

With Node v8.X.X use bcrypt >= 1.0.3 and < 3.0.0 (source: front page)

OHH !! … hangs head in shame

@stridentbean Well I have a docker solution as well but I add a couple more dependecies to make bcrypt work in my image :

FROM node:8

RUN apt-get update && apt-get install -y build-essential && apt-get install -y python
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY package.json /usr/src/app/package.json
RUN npm install
COPY . /usr/src/app
EXPOSE 9000
CMD ["node", "."]

If any one still have this problem you can fix it by doing this

npm install -g node-gyp
npm install --g --production windows-build-tools

or install cmake and gcc on linux by using

sudo apt install cmake gcc -y 

Currently using node v8.12 I also had this problem today, fixed with by specifying a specific bcrypt version
yarn add bcrypt@3.0.2 This works for me. Device Configuration: Windows 10, npm version 6.4.1

Same issue with bcrypt@3.01 running on Ubuntu 18.04 LTS (npm@6.4.1/node@8.12.0).