The module bcrypt_lib was compiled against a different Nodejs version
When we were setting up the nodejs based REST API on the server we had to update the nodejs version. After we update the nodejs version we tried to run our existing nodejs application using npm.
As soon as we ran the npm install
, we got the following error:
Error: The module '/node_modules/bcrypt/lib/binding/bcrypt_lib.node' was compiled against a different Node.js version using NODE_MODULE_VERSION 51. This version of Node.js requires NODE_MODULE_VERSION 57. Please try re-compiling or re-installing the module (for instance, using `npm rebuild` or `npm install`).
Reason of the issue:
This happened due to the version of the nodejs. The bcrypt library was compiled with an older version of nodejs. On the error message, clearly mentioned it.
Solution of the issue:
To solve the above issue we had to remove the module folder (bcrypt) from the node_modules folder under our project.
$ rm -rf node_modules/bcrypt
Then we had to and reinstall it, use the following commands:
$ npm install
If the above approach does not solve your problem then you can try this StackOverflow post: