Node - was compiled against a different Node.js version using NODE_MODULE_VERSION 51
I am running a node application on terminal. Have recently upgraded to node v8.5.0, but am getting this error:
Error: The module '/tidee/tidee-au/packages/tidee-au-server/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`).
at Object.Module._extensions..node (module.js:653:18)
at Module.load (module.js:545:32)
at tryModuleLoad (module.js:508:12)
at Function.Module._load (module.js:500:3)
at Module.require (module.js:568:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/tidee/tidee-au/packages/tidee-au-server/node_modules/bcrypt/bcrypt.js:6:16)
at Module._compile (module.js:624:30)
at Module._extensions..js (module.js:635:10)
at Object.require.extensions.(anonymous function) [as .js] (/tidee/tidee-au/packages/tidee-au-server/node_modules/babel-register/lib/node.js:152:7)
at Module.load (module.js:545:32)
at tryModuleLoad (module.js:508:12)
at Function.Module._load (module.js:500:3)
at Module.require (module.js:568:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/tidee/tidee-au/packages/tidee-au-server/server/helpers/encryptPass.js:1:16)
Any idea how to solve this?
Solution 1:
You need to remove the module folder (bcrypt
) from the node_modules
folder and reinstall it, use the following commands:
$ rm -rf node_modules/bcrypt
$ npm install
// or
$ yarn
Solution 2:
I had the same problem and nothing mentioned here worked for me. Here is what worked for me:
- Require all dependencies you need in the
main.js
file that is run by electron. (this seemed to be the first important part for me) - Run
npm i -D electron-rebuild
to add the electron-rebuild package - Remove the
node-modules
folder, as well as thepackages-lock.json
file. - Run
npm i
to install all modules. - Run
./node_modules/.bin/electron-rebuild
(.\node_modules\.bin\electron-rebuild.cmd
for Windows) to rebuild everything
It is very important to run ./node_modules/.bin/electron-rebuild
directly after npm i
otherwise it did not work on my mac.
I hope I could help some frustrated souls.
Solution 3:
You have to rebuild the package and tell npm to update it's binary too. Try:
npm rebuild bcrypt --update-binary
@robertklep answered a relative question with this command, look.
Only rebuild haven't solved my problem, this works fine in my application.
Hope it helps!
Solution 4:
Simply run:
npm uninstall bcrypt
Followed by:
npm install bcrypt
(or npm install
, if bcrypt is declared as dependency in your package.json file)