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

bcrypt Installation Trouble

davik edited this page Mar 31, 2016 · 5 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.

If you find a problem with "node-gyp" then follow the various installation procedures of node-gyp. node-gyp is a Node.js native addon build tool, essential for bcrypt installation.

Alternatives

There have been requests for Drywall to use alternative modules instead. Some other modules are:

Why So Serious?

Some of the reasons I 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.7.7"
+  "bcryptjs": "~0.7.12"

One occurrence. Version numbers may be different.

Step #2 - Update ./init.js

-  var bcrypt = require('bcrypt');
+  var bcrypt = require('bcryptjs');

Step #3 - Update /schema/User.js

-  var bcrypt = require('bcrypt');
+  var bcrypt = require('bcryptjs');

Two occurrences.

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

Use the Force

I 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.