Module version mismatch. Expected 11, received 1

Platform: Linux 

When starting my node.js program, I got the following error:

 Error: Module version mismatch. Expected 11, got 1. 
+44
Mar 23 '13 at 7:45
source share
14 answers

you can indicate an error:

 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 may notice an error in the module or somewhere.

this is because you updated your node, you can rebuild the module found above.

i revole my question reinstall (uninstall, then install) xml2json.

Good luck

+54
Mar 25 '13 at 7:35
source share

npm rebuild will also do the trick

https://www.npmjs.org/doc/cli/npm-rebuild.html

+34
Oct 14 '14 at 22:26
source share
 Platform: Linux 

For future reference, 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 got some help from Ben Noordhuis . The following command helped me get rid of this error:

 npm update 
+18
Mar 23 '13 at 7:45
source share

This usually happens when you install a package using one version of Node, and then change to another version. This can happen when upgrading Node or switching to another version using nvm.

This can also happen if you are trying to start a process with root privileges with Node installed globally, but you are using a managed nvm node in your user account.

To fix this, you can simply reinstall the packages using the correct version of Node. Also make sure that you are using the same version of node for different users.

+11
Apr 29 '13 at 21:51
source share

This problem occurs because of the following scenario: you use Node, for example, version 5. You add several libraries to your project, create and run them. All your libraries will be compiled in Node version 5.

And then you upgrade your Node, for example, to version 6. And then you run some commands that use node, for example npm run test . The problem here is: you are using a newer version of Node to run libraries compiled by older node.

The solution to this problem is performed by the following two commands:

 rm -rf node_modules // force remove node_modules directory npm install // install again all libraries. 
+4
Oct 17 '16 at 19:41
source share

Another thing to try if you are using nvm is to make sure that you are using the same version of node in both the global and the application.

 :/$ node -v v6.0.0 :/var/www/app$ node -v v6.2.0 

If they do not agree:

 :/$ nvm use 6.2.0 Now using node v6.2.0 (npm v3.8.9) 

(This is what worked for me.)

+3
Jun 11 '16 at 1:15
source share

You can find a list of node module versions and their corresponding node version on this page https://nodejs.org/en/download/releases/

NODE_MODULE_VERSION refers to the version number of the ABI (application binary interface) Node.js used to determine which versions of Node.js of compiled C ++ executable binaries can be downloaded without having to be reused, compiled. It used to be stored as a hexadecimal value in earlier versions, but now it is represented as an integer.

+2
Feb 10 '16 at 10:42 on
source share

Sometimes the problem arises due to the version of nodejs.

Try updating the version of npm and nodejs. Follow this link to update your sites.

And update using npm:

 sudo npm install npm -g 

Hope this helps!

+1
Oct 13 '17 at 8:04 on
source share

In my case, the cause of the error was C ++ - AddOn, which was compiled with another version of node.js.

So you may have to recompile your C ++ - AddOn, so the major versions of the addon and node.js will be executed.

0
Aug 02 '16 at 13:47 on
source share

I had this problem with systemd, but I could run the application using node myapp.js .

It turns out that the path in ExecStart was different from the path I got from which node . Changing this in the service file fixed this for me.

source

0
Jul 30 '17 at 9:30
source share

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) Error: Module version mismatch. Expected 48, got 51. at Error (native) at Object.Module._extensions..node (module.js:597:18) 48 and 51 correspond to the node versions found on the nodejs release page: https://nodejs.org/ en / download / releases /

So, I installed nvm, the node version manager and switched my node version to 48 (6.11.x), and then ran rm -rf node_modules/ as well as npm install

My specific module, mcrypt, is dependent on C ++ binaries, and the version of the node module has a direct effect:

NODE_MODULE_VERSION refers to the version number of the ABI (application binary interface) Node.js used to determine which versions of Node.js of compiled C ++ executable binaries can be downloaded without having to be reused, compiled. It used to be stored as a hexadecimal value in earlier versions, but now it is represented as an integer.

0
Oct 17 '17 at 20:26
source share

The easiest way to get to where you need to, after you have changed the version of your site, is:

rm -Rf node_modules/&& yarn && yarn start

Replace yarn start whatever command you need to start the server.

0
Jan 05 '18 at 20:19
source share

If the module is a c ++ add-in, you may have to rebuild node-gyp

 node-gyp rebuild 
0
May 19 '18 at 15:16
source share

None of the above answers solved the problem for me. The solution for me was to use xml2js instead of xml2json .

0
Dec 11 '18 at 12:49
source share



All Articles