Nodejs Bcrypt + Heroku fail deploy

Had the same thing happening to me.

Node version not specified in package.json

Try and do what heroku suggest, define the node version you are using on the package.json.

Get the version you are using for development:

node --version

Then put it on package.json:

{ "name": "myapp", 
  "description": "a really cool app",  
  "version": "1.0.0", 
  "engines": { 
      "node": "8.9.4" 
   }
}

I got same behaviour for node 8.12 in travis ci since last days.

Looks like nodejs release new nodejs version 8.12 few days ago and bcrypt don't have prebuild for that version, but their script for build from source fails on linux.

Also for nodejs 8 recommended to use bcrypt 1.0.3 according their version compatibility.

Check github issue for more details: https://github.com/kelektiv/node.bcrypt.js/issues/648


Well I tried the solution by @GMachado and it did not work for me.

I know this happens because bcrypt requires a native compiler. I used python to compile bcrypt on my local machine but i am not willing to go through this stress when deploying on heroku

As a quick solution, I unistalled bcrypt then installed bcryptjs, bcryptjs is the pure-javascript version of bcrypt. Just think of it as a light version of bcrypt. While bcrypt requires native compiler to compile, bcryptjs does not. bcrypt is about 1.3 times faster than bcryptjs. thats the major difference.

First uninstall bcrypt by typing in the command:

npm uninstall --save bcrypt

Then install bcryptjs by typing in the command

npm install --save bcryptjs

Afterwards, Navigate to where you have imported bcrypt on your app and change it to

require("bcryptjs")

the rest of the application should remain the same.

Go back to deploy on heroku and you should be fine.