vidly-api-node icon indicating copy to clipboard operation
vidly-api-node copied to clipboard

React 2019 Course | Bcrypt error

Open JonattanD1440 opened this issue 5 years ago • 12 comments

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.

JonattanD1440 avatar Dec 25 '19 12:12 JonattanD1440

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

mamoyz avatar Jan 04 '20 22:01 mamoyz

I faced the same error but instead of changing files, I just installed bcrypt@latest and it is working just fine. Hope it helps

pouriamoosavi avatar Jan 09 '20 19:01 pouriamoosavi

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)"

jalexandremoreira avatar Jan 15 '20 16:01 jalexandremoreira

@mamoyz very helpful bro! God bless you man!

ybakhshi avatar Feb 01 '20 12:02 ybakhshi

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 avatar Feb 01 '20 17:02 factorlive

@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?

ybakhshi avatar Feb 02 '20 22:02 ybakhshi

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);

Ozball avatar Mar 20 '20 06:03 Ozball

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")

abdulloooh avatar May 10 '20 10:05 abdulloooh

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)

averyfreeman avatar May 16 '20 18:05 averyfreeman

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

qlian100 avatar May 22 '20 00:05 qlian100

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!

mrluisrodriguez19 avatar Jul 08 '20 16:07 mrluisrodriguez19

It gave me 404 error and I changed the Bcrypt version in package.json to the last version.

amir2mi avatar Sep 27 '21 10:09 amir2mi