Home > Software design >  npm ERR! when trying to install bcrypt on npm nodejs
npm ERR! when trying to install bcrypt on npm nodejs

Time:01-31

I want to install bcrypt in my node js with the command "npm install bcrypt" but it doesn't work.

I have tried uninstalling and reinstalling it but still the error

any suggestions that can help? thank you

PS E:\OneDrive\Documents\log&reg\logresjwt> npm install bcrypt

> [email protected] install E:\OneDrive\Documents\log&reg\logresjwt\node_modules\bcrypt
> node-pre-gyp install --fallback-to-build

'reg\logresjwt\node_modules\.bin\' is not recognized as an internal or external command,
operable program or batch file.
internal/modules/cjs/loader.js:883
  throw err;
  ^

Error: Cannot find module 'E:\OneDrive\Documents\@mapbox\node-pre-gyp\bin\node-pre-gyp'       
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)       
    at internal/main/run_main_module.js:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}
npm WARN [email protected] No description
npm WARN [email protected] No repository field.

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\ASUS\AppData\Roaming\npm-cache\_logs\2022-01-28T16_18_13_219Z-debug.log

PS E:\OneDrive\Documents\log&reg\logresjwt> node-pre-gyp install --fallback-to-build 
node-pre-gyp : The term 'node-pre-gyp' is not recognized as the name of a cmdlet, function,

CodePudding user response:

It is because of the bcrypt module dependency node-gyp. I suggest you use a library bcryptjs which has no dependencies and more downloads.

npm i bcryptjs --save

and dont forget to uninstall

npm uninstall bcrypt --save

On top of that brcypt has more dependecies like python 2.x. This will be also an issue on deployment also. It is better to use libraries with no dependencies. https://www.npmjs.com/package/bcryptjs

CodePudding user response:

You should install node-gyp globally on your pc.

sudo npm install -g node-gyp
then npm install bcrypt

  •  Tags:  
  • Related