Nodejs Bcrypt + Heroku fail deploy

后端 未结 3 1049
遥遥无期
遥遥无期 2020-12-18 23:08

i am having problems when i try to do a deployment in heroku. The funny part is this was working three days ago. Also, is working fine in local machine.

The version

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-19 00:01

    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.

提交回复
热议问题