Error while installing bycrpt in nodejs? whenever i run npm install install --save?

12,966

Solution 1

You should use

npm install --save bcrypt

for a proper installation.

By the way to use bcrypt you need python installed. If you want be python-independent use bcryptjs

npm install --save bcryptjs

Solution 2

Have you tried this?

Open powershell with administrator privileges and run this command, then proceed with bcrypt installation.

npm install --global --production windows-build-tools

Note: Wait until you see "All Done!" on the powershell window and then proceed to install the module.

Solution 3

You need to install bcrypt separately.

do npm install bcrypt --save and after this is done, run npm install again.

You can also check out this link for an answer to a similar question.

Alternatively, if this doesn't work, you can use bcrypt-nodejs or bcryptjs package.

Solution 4

For some that may encounter that

Case

If you were able to install correctly before. Then after upgrading your nodejs (for me i went from 11 to 12) you become unable.

If you get

was compiled against a different Node.js version using
NODE_MODULE_VERSION 64. This version of Node.js requires
NODE_MODULE_VERSION 72. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).

an error like that. And then when you run npm rebuild you end up with other errors.

Solution that can work (did for me)

Remove completly bcrypt. (remove from package.json then npm install --save).

Then reinstall again

npm install bcrypt --save 

It installed correctly and build up with no problem.

(You may omit the remove part).

Solution 5

try with this version ..its working for me ... npm i [email protected]

Share:
12,966
aditya kumar
Author by

aditya kumar

Updated on August 01, 2022

Comments

  • aditya kumar
    aditya kumar almost 2 years
    > [email protected] install C:\projects\alecadApi\node_modules\bcrypt
    > node-pre-gyp install --fallback-to-build
    
    `node-pre-gyp` WARN Tried to download(404): https://github.com/kelektiv/node.bcrypt.js/releases/download/v3.0.0/bcrypt_lib-v3.0.0-node-v57-win32-x64-unknown.tar.gz
    `node-pre-gyp` WARN Pre-built binaries not found for [email protected] and [email protected] (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.
    `C:\projects\alecadApi\node_modules\bcrypt\build\bcrypt_lib.vcxproj(20,3)`: error MSB4019: The imported project "C:\Microsoft.Cp
    p.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk
    .
    `gyp ERR!` build error
    `gyp ERR!` stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
    gyp ERR! stack     at ChildProcess.onExit (C:\Users\adity\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\build.js:258: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:\\Users\\adity\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "build" "--fallback-to-build" "--module=C:\\projects\\alecadApi\\node_modules\\bcrypt\\lib\\binding\\bcrypt_lib.node" "--module_name=bcrypt_lib" "--module_path=C:\\projects\\alecadApi\\node_modules\\bcrypt\\lib\\binding" "--napi_version=1" "--node_abi_napi=napi"
    `gyp ERR!` cwd C:\projects\alecadApi\node_modules\bcrypt
    `gyp ERR`! node -v v8.10.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 'C:\Program Files\nodejs\node.exe C:\Users\adity\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --module=C:\projects\alecadApi\node_modules\bcrypt\lib\binding\bcrypt_lib.node --module_name=bcrypt_lib --module_path=C:\projects\alecadApi\node_modules\bcrypt\lib\binding --napi_version=1 --node_abi_napi=napi' (1)
    node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (C:\Projects\alecadApi\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:925: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:\\Projects\\alecadApi\\node_modules\\bcrypt\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build"
    `node-pre-gyp` ERR! cwd C:\projects\alecadApi\node_modules\bcrypt
    `node-pre-gyp` ERR! node -v v8.10.0
    `node-pre-gyp` ERR! node-pre-gyp -v v0.10.2
    `node-pre-gyp` ERR! not ok
    Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\adity\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --module=C:\projects\alecadApi\node_modules\bcrypt\lib\binding\bcrypt_lib.node --module_name=bcrypt_lib --module_path=C:\projects\alecadApi\node_modules\bcrypt\lib\binding --napi_version=1 --node_abi_napi=napi' (1)
    `npm WARN` [email protected] No repository field.
    `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":"win32","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!`     C:\Users\adity\AppData\Roaming\npm-cache\_logs\2018-07-07T10_51_34_631Z-debug.log```
    
    • Ankit Halder
      Ankit Halder almost 6 years
      just type npm install bcrypt --save in you terminal
  • user2402616
    user2402616 almost 4 years
    Spent over an hour trying to figure this out. YOur simple soln worked. Thanks!
  • Jaskaran Singh
    Jaskaran Singh about 3 years
    This solved my problem perfectly. windows-build-tools supports all pure C++ addons for Node.js Those are: node-sass, bcrypt, sqlite3, serialport, websocket, deasync, grpc, canvas, sharp, hiredis, leveldown, nodegit, zqm, ffi, libxmljs, iconv, ref, sleep, microtime, couchbase, bignum, kerberos, and ursa.
  • mrSerious
    mrSerious about 2 years
    Happy to hear this. :)