Platform: Linux
When running my node.js program I got the following error
Error: Module version mismatch. Expected 11, got 1.
Platform: Linux
When running my node.js program I got the following error
Error: Module version mismatch. Expected 11, got 1.
you might give the error like this:
Error: Module version mismatch. Expected 11, got 1.
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/home/user/node_modules/xml2json/node_modules/node-expat/lib/node-expat.js:4:13)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
and then, you can notice the error in module or somewhere.
this is because you have updated your node, you might rebuild the module found above.
i revole my question by reinstall(remove, then install) xml2json.
good luck!
Platform: Linux
For future reference in node.js v0.10.x
(at least v0.10.0) I got this error:
Error: Module version mismatch. Expected 11, got 1.
To fix this I found this interesting link and also had some help from Ben Noordhuis. The following command helped me get rid of this error:
npm update
This usually happens when you install a package using one version of Node, then change to a different version. This can happen when you update Node, or switch to a different version with nvm.
It can also happen if you're trying to run a process as root with a globally installed Node, but you're running an nvm-managed node within your own user account.
To fix this, you can simply re-install the packages using the correct version of Node. Also ensure that you're using the same version of Node across the different users.
This problem is happened because following scenario: you are using Node for example version 5. You add some libraries inside your project, build and run that. All your libraries will be compiled under node version 5.
And then you upgrade your node for example to version 6. And then you run some commands that using node, for example npm run test
. The problem is here: you use newer node version for running libraries that compiled by older node.
Solving this is easy by 2 following commands:
rm -rf node_modules // force remove node_modules directory
npm install // install again all libraries.
One more thing to try if you're using nvm- make sure you are running the same version of node globally as well as within the app.
:/$ node -v
v6.0.0
:/var/www/app$ node -v
v6.2.0
If they aren't in agreement:
:/$ nvm use 6.2.0
Now using node v6.2.0 (npm v3.8.9)
(This is what worked for me.)
You can find a list of node module versions and their corresponding node release on this page https://nodejs.org/en/download/releases/
NODE_MODULE_VERSION refers to the ABI (application binary interface) version number of Node.js, used to determine which versions of Node.js compiled C++ add-on binaries can be loaded in to without needing to be re-compiled. It used to be stored as hex value in earlier versions, but is now represented as an integer.
In my case the reason for the error was a C++-AddOn which was compiled against a different node.js Version.
So you might have to recompile your C++-AddOn, so the major versions of the addon and the node.js you run match.
None of the answers worked for me, so here is my solution.
Error: Module version mismatch. Expected 48, got 51.
at Error (native)
at Object.Module._extensions..node (module.js:597:18)
The 48 and 51 correspond to node versions as found on nodejs release page:
https://nodejs.org/en/download/releases/
So I installed nvm, a node version manager, and switched my node version to 48 (6.11.x) and then ran
rm -rf node_modules/
and
npm install
My particular module, mcrypt, depended on c++ binaries, and the Node Module Version has a direct impact:
NODE_MODULE_VERSION refers to the ABI (application binary interface) version number of Node.js, used to determine which versions of Node.js compiled C++ add-on binaries can be loaded in to without needing to be re-compiled. It used to be stored as hex value in earlier versions, but is now represented as an integer.
The easiest way to get to where you need to be, after you've changed your node version is:
rm -Rf node_modules/ && yarn && yarn start
Replace yarn start
with whatever the command is that you need to start your server.
If the module is a c++ add-on, you may have to rebuild the node-gyp
node-gyp rebuild