vidly-api-node
vidly-api-node copied to clipboard
React 2019 Course | Bcrypt error
Unable to run "npm i", because i'm getting a bcrypt error unable to download and some other dependencies like node, node-gyp and node-pre-gy. My solution was to installing these packages on their own and instead of using bcrypt, i used bcryptjs. Afterwards you need to go into the auth and users file and change: const bcrypt = require("bcrypt"); to const bcrypt = require("bcryptjs"); and it should be working fine.
Unable to run "npm i", because i'm getting a bcrypt error unable to download and some other dependencies like node, node-gyp and node-pre-gy. My solution was to installing these packages on their own and instead of using bcrypt, i used bcryptjs. Afterwards you need to go into the auth and users file and change: const bcrypt = require("bcrypt"); to const bcrypt = require("bcryptjs"); and it should be working fine.
Open file "package.json" and remove "bcrypt"
Then Install bcrypt-nodejs using:
npm install --save bcrypt-nodejs && npm uninstall --save bcrypt
Replace "bcrypt" with "bcrypt-nodejs" in these files:
\vidly-api-node\routes\users.js
\vidly-api-node\routes\auth.js
I faced the same error but instead of changing files, I just installed bcrypt@latest and it is working just fine. Hope it helps
Even after trying some of the above proposed solutions and also following some advice from a friend, I still have no success. I'm still left with: "3 vulnerabilities (2 moderate, 1 high)"
@mamoyz very helpful bro! God bless you man!
Do follow @pouriamoosavi advice and install the latest bcrypt.
npm i bcrypt@latest
No need to edit package.json for me.
Running MacOs 10.14.6 and using the git repo as opposed to the zip file on Mosh page behind the paywall.
@factorlive i updated the bcrypt to latest but on windows 10 it didn't work out . but solution from @mamoyz worked out. I have now another issue with users . i get a 500 internal server error while submitting the registration form! any solution?
I have now another issue with users . i get a 500 internal server error while submitting the registration form! any solution?
@ybakhshi if you're still having issues with this, I believe I've found a solution. If using bcrypt-nodejs as @mamoyz suggests then the following two lines need adjusting in users.js
Line 21: const salt = await bcrypt.genSalt(10); changes to const salt = await bcrypt.genSaltSync(10);
and Line 22: user.password = await bcrypt.hash(user.password, salt); changes to user.password = await bcrypt.hashSync(user.password, salt);
This seemed to get around the issue for me.
Also if you then run into issues during the login form section replace auth.js:Line 16 const validPassword = await bcrypt.compare(req.body.password, user.password); with const validPassword = await bcrypt.compareSync(req.body.password, user.password);
Unable to run "npm i", because i'm getting a bcrypt error unable to download and some other dependencies like node, node-gyp and node-pre-gy. My solution was to installing these packages on their own and instead of using bcrypt, i used bcryptjs. Afterwards you need to go into the auth and users file and change: const bcrypt = require("bcrypt"); to const bcrypt = require("bcryptjs"); and it should be working fine.
Open file "package.json" and remove "bcrypt"
Then Install bcrypt-nodejs using:
npm install --save bcrypt-nodejs && npm uninstall --save bcrypt
Replace "bcrypt" with "bcrypt-nodejs" in these files:
\vidly-api-node\routes\users.js \vidly-api-node\routes\auth.js
If you are installing bcryptjs in 2020, you are going to change require("bcrypt")
to require("bcrypt-nodejs")
and not require("bcryptjs")
Even after trying some of the above proposed solutions and also following some advice from a friend, I still have no success. I'm still left with: "3 vulnerabilities (2 moderate, 1 high)"
If you tried installing bcrypt
already and are planning to change to bcryptjs
, try removing bcrypt
first (had similar error, and it worked for me)
if you get the error"bcrypt-nodejs is no longer actively maintained. Please use bcrypt or bcryptjs. "
This is what I did
Open file "package.json" and remove "bcrypt"
Then Install bcrypt-nodejs using: npm i bcrypt
I have now another issue with users . i get a 500 internal server error while submitting the registration form! any solution?
@ybakhshi if you're still having issues with this, I believe I've found a solution. If using bcrypt-nodejs as @mamoyz suggests then the following two lines need adjusting in users.js
Line 21: const salt = await bcrypt.genSalt(10); changes to const salt = await bcrypt.genSaltSync(10);
and Line 22: user.password = await bcrypt.hash(user.password, salt); changes to user.password = await bcrypt.hashSync(user.password, salt);
This seemed to get around the issue for me.
Also if you then run into issues during the login form section replace auth.js:Line 16 const validPassword = await bcrypt.compare(req.body.password, user.password); with const validPassword = await bcrypt.compareSync(req.body.password, user.password);
This did it for me. Thanks!
It gave me 404 error and I changed the Bcrypt version in package.json
to the last version.