Node.bcrypt.js: bcrypt 1.0.3 fails to build on Node v10.4 (Ubuntu 18.04)

Created on 12 Jun 2018  Â·  13Comments  Â·  Source: kelektiv/node.bcrypt.js

I cannot build bcrypt 1.0.3, despite having a compiler toolchain installed. The error log below may be helpful:

npm WARN deprecated [email protected]: bcrypt < v2.0.0 is susceptible to bcrypt wrap-around bug. Upgrade to bcrypt >= v2.0.0 for improved support for newer bcrypt hashes

[email protected] install /home/gclaugus/LynxChan/src/be/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.3/bcrypt_lib-v1.0.3-node-v64-linux-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v64 ABI) (falling back to source compile with node-gyp)
node-pre-gyp ERR! Tried to download(undefined): https://github.com/kelektiv/node.bcrypt.js/releases/download/v1.0.3/bcrypt_lib-v1.0.3-node-v64-linux-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v64 ABI) (falling back to source compile with node-gyp)
make: Entering directory '/home/gclaugus/LynxChan/src/be/node_modules/bcrypt/build'
CXX(target) Release/obj.target/bcrypt_lib/src/blowfish.o
make: Entering directory '/home/gclaugus/LynxChan/src/be/node_modules/bcrypt/build'
CXX(target) Release/obj.target/bcrypt_lib/src/blowfish.o
rm: cannot remove './Release/.deps/Release/obj.target/bcrypt_lib/src/blowfish.o.d.raw': No such file or directory
bcrypt_lib.target.mk:97: recipe for target 'Release/obj.target/bcrypt_lib/src/blowfish.o' failed
make: * [Release/obj.target/bcrypt_lib/src/blowfish.o] Error 1
make: Leaving directory '/home/gclaugus/LynxChan/src/be/node_modules/bcrypt/build'
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt.o
at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack at ChildProcess.emit (events.js:182:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:237:12)
gyp ERR! System Linux 4.15.0-22-generic
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/home/gclaugus/LynxChan/src/be/node_modules/bcrypt/lib/binding/bcrypt_lib.node" "--module_name=bcrypt_lib" "--module_path=/home/gclaugus/LynxChan/src/be/node_modules/bcrypt/lib/binding"
gyp ERR! cwd /home/gclaugus/LynxChan/src/be/node_modules/bcrypt
gyp ERR! node -v v10.4.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/home/gclaugus/LynxChan/src/be/node_modules/bcrypt/lib/binding/bcrypt_lib.node --module_name=bcrypt_lib --module_path=/home/gclaugus/LynxChan/src/be/node_modules/bcrypt/lib/binding' (1)
node-pre-gyp ERR! stack at ChildProcess. (/home/gclaugus/LynxChan/src/be/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:182:13)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:961:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:248:5)
node-pre-gyp ERR! System Linux 4.15.0-22-generic
node-pre-gyp ERR! command "/usr/bin/node" "/home/gclaugus/LynxChan/src/be/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /home/gclaugus/LynxChan/src/be/node_modules/bcrypt
node-pre-gyp ERR! node -v v10.4.0
node-pre-gyp ERR! node-pre-gyp -v v0.6.36
node-pre-gyp ERR! not ok
Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/home/gclaugus/LynxChan/src/be/node_modules/bcrypt/lib/binding/bcrypt_lib.node --module_name=bcrypt_lib --module_path=/home/gclaugus/LynxChan/src/be/node_modules/bcrypt/lib/binding' (1)
../src/bcrypt.cc: In function ‘void encode_salt(char, u_int8_t, u_int16_t, u_int8_t)’:
../src/bcrypt.cc:132:1: warning: ‘__builtin___snprintf_chk’ output may be truncated before the last format character [-Wformat-truncation=]
encode_salt(char salt, u_int8_t *csalt, u_int16_t clen, u_int8_t logr)
^~~
In file included from /usr/include/stdio.h:862:0,
from ../src/bcrypt.cc:48:
/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:165: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:48:
/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:322: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:97: 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/gclaugus/LynxChan/src/be/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/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack at ChildProcess.emit (events.js:182:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:237:12)
gyp ERR! System Linux 4.15.0-22-generic
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/home/gclaugus/LynxChan/src/be/node_modules/bcrypt/lib/binding/bcrypt_lib.node" "--module_name=bcrypt_lib" "--module_path=/home/gclaugus/LynxChan/src/be/node_modules/bcrypt/lib/binding"
gyp ERR! cwd /home/gclaugus/LynxChan/src/be/node_modules/bcrypt
gyp ERR! node -v v10.4.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: node-pre-gyp install --fallback-to-build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Most helpful comment

npm i [email protected]
Worked !!

All 13 comments

We did not test v1.0.3 with Node 10, they are deprecated.

However, it does compile. It seems like there is some other error.

I had the same issue, but in Manjaro.
To fix it, i changed the python link in /usr/bin , to python3 to python2.

sudo ln -sf python2 python

@impo fatal error: opening dependency file ./Release/.deps/Release/obj.target/bcrypt_lib/src/bcrypt.o.d.raw: No such file or directory

Looks like something is removing the compiled binaries

v1.0.3 does not reliably compile under node 10. We have marked that version as deprecated.

LynxChan dev here, I recommend to use node 8 in the version that uses bcryp 1.x, it's in the readme. So the fix would be to install node 8.

I'm having the exact same issue here, but I don't know how to change the bcrypt version? My project only relies on express, but for some reason when I'm running npm install it's trying to install bcrypt. I don't see it in my package lock, so I have no idea why it's getting pulled in as a dependency? It seems like it's trying to get 1.0.3 -- I have no idea why. I'm using node 10 on Ubuntu 18.04 just like in the question. I'm happy to use a more recent version of bcrypt, but I have no idea where to specify it because somehow 1.0.3 is being pulled in magically. I'd love some guidance on this!

Hi! I have the same problem but with node 8:

$ npm i bcrypt

> [email protected] install /home/ivan/projects/nevadacoinmart/auth/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 Pre-built binaries not installable for [email protected] and [email protected] (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/ivan/projects/nevadacoinmart/auth/node_modules/bcrypt/build'
  CXX(target) Release/obj.target/bcrypt_lib/src/blowfish.o
  CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt.o
../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 ());
                                            ^
  CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt_node.o
node-pre-gyp WARN Pre-built binaries not installable for [email protected] and [email protected] (node-v57 ABI, glibc) (falling back to source compile with node-gyp) 
node-pre-gyp WARN Hit error bad download 
make: Entering directory '/home/ivan/projects/nevadacoinmart/auth/node_modules/bcrypt/build'
  CXX(target) Release/obj.target/bcrypt_lib/src/blowfish.o
  CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt.o
../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_node.cc:375:30: fatal error: opening dependency file ./Release/.deps/Release/obj.target/bcrypt_lib/src/bcrypt_node.o.d.raw: No such file or directory
 NODE_MODULE(bcrypt_lib, init);
                              ^
compilation terminated.
bcrypt_lib.target.mk:103: recipe for target 'Release/obj.target/bcrypt_lib/src/bcrypt_node.o' failed
make: *** [Release/obj.target/bcrypt_lib/src/bcrypt_node.o] Error 1
make: Leaving directory '/home/ivan/projects/nevadacoinmart/auth/node_modules/bcrypt/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/home/ivan/.nvm/versions/node/v8.12.0/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-33-generic
gyp ERR! command "/home/ivan/.nvm/versions/node/v8.12.0/bin/node" "/home/ivan/.nvm/versions/node/v8.12.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/home/ivan/projects/nevadacoinmart/auth/node_modules/bcrypt/lib/binding/bcrypt_lib.node" "--module_name=bcrypt_lib" "--module_path=/home/ivan/projects/nevadacoinmart/auth/node_modules/bcrypt/lib/binding" "--napi_version=3" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v57"
gyp ERR! cwd /home/ivan/projects/nevadacoinmart/auth/node_modules/bcrypt
gyp ERR! node -v v8.12.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
../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 ());
                                            ^
node-pre-gyp ERR! build error 
node-pre-gyp ERR! stack Error: Failed to execute '/home/ivan/.nvm/versions/node/v8.12.0/bin/node /home/ivan/.nvm/versions/node/v8.12.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/home/ivan/projects/nevadacoinmart/auth/node_modules/bcrypt/lib/binding/bcrypt_lib.node --module_name=bcrypt_lib --module_path=/home/ivan/projects/nevadacoinmart/auth/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.<anonymous> (/home/ivan/projects/nevadacoinmart/auth/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-33-generic
node-pre-gyp ERR! command "/home/ivan/.nvm/versions/node/v8.12.0/bin/node" "/home/ivan/projects/nevadacoinmart/auth/node_modules/bcrypt/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /home/ivan/projects/nevadacoinmart/auth/node_modules/bcrypt
node-pre-gyp ERR! node -v v8.12.0
node-pre-gyp ERR! node-pre-gyp -v v0.11.0
node-pre-gyp ERR! not ok 
Failed to execute '/home/ivan/.nvm/versions/node/v8.12.0/bin/node /home/ivan/.nvm/versions/node/v8.12.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/home/ivan/projects/nevadacoinmart/auth/node_modules/bcrypt/lib/binding/bcrypt_lib.node --module_name=bcrypt_lib --module_path=/home/ivan/projects/nevadacoinmart/auth/node_modules/bcrypt/lib/binding --napi_version=3 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v57' (1)
make: *** No rule to make target '../src/bcrypt_node.cc', needed by 'Release/obj.target/bcrypt_lib/src/bcrypt_node.o'.  Stop.
make: Leaving directory '/home/ivan/projects/nevadacoinmart/auth/node_modules/bcrypt/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/home/ivan/.nvm/versions/node/v8.12.0/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-33-generic
gyp ERR! command "/home/ivan/.nvm/versions/node/v8.12.0/bin/node" "/home/ivan/.nvm/versions/node/v8.12.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/home/ivan/projects/nevadacoinmart/auth/node_modules/bcrypt/lib/binding/bcrypt_lib.node" "--module_name=bcrypt_lib" "--module_path=/home/ivan/projects/nevadacoinmart/auth/node_modules/bcrypt/lib/binding" "--napi_version=3" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v57"
gyp ERR! cwd /home/ivan/projects/nevadacoinmart/auth/node_modules/bcrypt
gyp ERR! node -v v8.12.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] 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/ivan/.npm/_logs/2018-09-27T09_11_49_836Z-debug.log

I could installed the bcrypt after manually installed the node-gyp

I'm having the exact same issue here, but I don't know how to change the bcrypt version? My project only relies on express, but for some reason when I'm running npm install it's trying to install bcrypt. I don't see it in my package lock, so I have no idea why it's getting pulled in as a dependency? It seems like it's trying to get 1.0.3 -- I have no idea why. I'm using node 10 on Ubuntu 18.04 just like in the question. I'm happy to use a more recent version of bcrypt, but I have no idea where to specify it because somehow 1.0.3 is being pulled in magically. I'd love some guidance on this!

I have the same issue as @aardvarkk , on a Windows machine - bcrypt 1.0.3 gets pulled even when I delete the lines in my package-lock and try to download bcrypt again.

npm install bcrypt
npm WARN deprecated [email protected]: bcrypt < v2.0.0 is susceptible to bcrypt wrap-around bug. Upgrade to bcrypt >= v2.0.0 for improved support

@armelchiza Do an npm ls and see which package is pulling bcrypt v1.0.3. It's not really a bcrypt issue. Upgrade the affected package

npm i [email protected]
Worked !!

npm i [email protected] worked for me too

npm i [email protected] worked for me also

Was this page helpful?
0 / 5 - 0 ratings