npm - Node - was compiled against a different Node.js version using NODE_MODULE_VERSION 51

ID : 20097

viewed : 21

Tags : node.jsnpmversionnode-modulesnode.js

Top 5 Answer for npm - Node - was compiled against a different Node.js version using NODE_MODULE_VERSION 51

vote vote

94

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 
vote vote

84

I had the same problem and nothing mentioned here worked for me. Here is what worked for me:

  1. 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)
  2. Run npm i -D electron-rebuild to add the electron-rebuild package
  3. Remove the node-modules folder, as well as the packages-lock.json file.
  4. Run npm i to install all modules.
  5. 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.

vote vote

76

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!

vote vote

61

Simply run:

npm uninstall bcrypt

Followed by:

npm install bcrypt (or npm install, if bcrypt is declared as dependency in your package.json file)

vote vote

58

Be sure you only have one version of NodeJS installed. Try these two:

node --version sudo node --version 

I initially installed NodeJS from source, but it was the incorrect version and 'upgraded' to the newest version using nvm, which doesn't remove any previous versions, and only installs the desired version in the /root/.nvm/versions/... directory. So sudo node was still pointing to the previous version, whilst node was pointing to the newer version.

Top 3 video Explaining npm - Node - was compiled against a different Node.js version using NODE_MODULE_VERSION 51

Related QUESTION?