I'm trying to start a nodeJS application, but I do get the error
Error: The module '/Users/api/node_modules/bcrypt/lib/binding/bcrypt_lib.node' was compiled against a different Node.js version using NODE_MODULE_VERSION 46. 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`).
I already run npm install
and npm rebuild
. But still the same error...
As on the same machine, we can only install one version of the nodejs, so it's very painful to uninstall and install the new node version as per your project requirements. To overcome this problem, we can use the Node Version Manager (NVM).
Usually, we work on different versions for our Node. js project and it's hard to manage them, but fortunately, there is a tool called NVM(node version manager) which helps to manage your node version and switch between them according to your projects.
So you can have multiple versions of the same package running in your app and you can work on the upgrades mitigating possible issues.
You can always copy node_modules and then run npm install or npm update in the new project to make sure you've got up-to-date versions. npm will use the files in node_modules as a cache and should only bring down newer content if required. In short: it won't hurt.
The bcrypt
package needs to be rebuild, because it was initially installed with another version of Node.js.
Try this:
npm rebuild bcrypt --update-binary
for yarn users:
yarn add bcrypt --force
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With