I am getting error Cannot find module \'bcrypt\' in nodejs application
I have tried to install it using npm install bcrypt but still gett
You need to update the g++ compiler version in your linux system. To update the compiler just run the commands below:
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-4.9 g++-4.9
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.9
npm install bcrypt --save
Be sure you are in a stable version of node too. If you are working with n
, you only need to:
sudo n stable
And then again:
npm install bcrypt --save
And it worked for me.
If this is an error you are facing when using something like Travis CI, consider using npm install --build-from-source
.
Check your node version and then go to this link https://github.com/kelektiv/node.bcrypt.js to match compatible bcrypt version with your node.js version
I am using node.js v14.7.0 and when I tried to run 'npm install bcrypt or bcryptjs' it gives me errors then I run npm install bcrypt@5.0.0
and the error fixed.
Version Compatibility
From: Cannot find module 'bcrypt'
Use bcrypt version according to node version.
Try to install bcrypt npm package separately like this If your node version is 8 use this command line
npm install bcrypt@1 --save
If your node version is 10,11 use this command line
npm install bcrypt@3 --save
maybe its will help you..
PS For me the second cmd worked and my Node version is 14.
In my case, npm rebuild
alone didn't solved it. I also had to:
$ npm install -g node-gyp
$ sudo apt-get update
$ sudo apt-get install build-essential
$ npm rebuild
npm rebuild
was trying to run make
.