Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Databases

Michael Wilkens
Michael Wilkens
7,976 Points

npm install error *fixed*

Perhaps some of you ran into an error when installing bcrypt like I did in my macOS terminal.

Initially, this threw an error: npm install --save bcrypt

So instead, I typed: npm install --save bcrypt-nodejs && npm uninstall --save bcrypt

I am assuming this loads a newer version of bcrypt. I then required bcrypt in the user.js file like this: var bcrypt = require('bcrypt-nodejs');

And the bcrypt hashing code looks like this: UserSchema.pre('save', function(next) { var user = this; bcrypt.hash(user.password, null, null, function(err, hash) { if (err) { return next(err); } user.password = hash next(); }); });

The only difference is in the hash function, instead of typing 10, you type null twice. Maybe I am the only one who had this problem, but I thought I would share anyway.

I'm still curious why I had an error in the first place. Maybe the video is just older, and bcrypt-nodejs is the new standard?