Skip to content
This repository has been archived by the owner on Mar 9, 2018. It is now read-only.

bcrypt Installation Trouble

Reza Akhavan edited this page Sep 11, 2016 · 3 revisions

For some of us it's not always easy to install the bcrypt module.

$ npm install bcrypt --save

If you have issues installing this module, go see the dependencies over at ncb000gt/node.bcrypt.js. I suggest you try getting this working before using an alternative method. Who knows, it might just further enlighten you as a developer.

All that's required for Ubuntu

$ sudo apt-get install build-essential

Alternatives

Why So Serious?

Some of the reasons we chose bcrypt are:

  • it's repo has few open issues with over 200 closed
  • it's been updated relatively recently and seems to be more actively supported
  • the maintainers are trusted in the community

I'm not a security expert, but bcrypt-nodejs's docs say:

Native JS implementation of BCrypt for Node. Has the same functionality as node.bcrypt.js expect for a few tiny differences. Mainly, it doesn't let you set the seed length for creating the random byte array.

... and those tiny differences could mean a lot to someone who knows more than I do about security.

I Don't Care

Ok cool. I just wanted you to know that stuff before blindly swapping the modules out. It's really easy to do anyways.

Step #1 - Update /package.json

-  "bcrypt": "~0.8.0"
+  "bcryptjs": "~2.0.2"

One occurrence. Version numbers may be different.

Step #2 - Update require statements

-  var bcrypt = require('bcrypt');
+  var bcrypt = require('bcryptjs');
  • server/api/login.js
  • server/models/session.js
  • server/models/user.js
  • test/server/api/login.js
  • test/server/models/session.js
  • test/server/models/user.js

See that wasn't so hard. And now you know all this great stuff about bcrypt. 🤘

That's it

We hope this was helpful. If you have questions or think this page should be expanded please contribute by opening an issue or updating this page.