Kevin Keller
Kevin Keller

Reputation: 61

NodeJS Module "userid" Error: Module version mismatch. Expected 46, got 47

I get the following error when trying to start my server.js which requires the module "userid".

  module.js:460
  return process.dlopen(module, path._makeLong(filename));
                 ^

Error: Module version mismatch. Expected 46, got 47.
    at Error (native)
    at Object.Module._extensions..node (module.js:460:18)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:313:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (/root/backend/node_modules/userid/lib/userid.js:2:15)
    at Module._compile (module.js:435:26)
    at Object.Module._extensions..js (module.js:442:10)
    at Module.load (module.js:356:32)

How can I solve this issue?

Upvotes: 5

Views: 4058

Answers (3)

Serg
Serg

Reputation: 2427

Another reason of this problem is that you have several different node versions installed at your system and you manage them with nvm. If you run node index.js and if you run sudo node index.js it may results in running different node version.

So if you installed your application modules with npm install and then run application with sudo node index.js you will have Module version mismatch error. In such case make sure with nvm that sudo node... run the same version of node as your application expects.

Also, while fixing initial problem you may have problem with nvm described here Can't use NVM from root (or sudo). One of possible solutions to this issue described in Yoo Matsuo's comment.

Upvotes: 0

Fintan Kearney
Fintan Kearney

Reputation: 764

I would try upgrading the module version that causes the issue on package.json.

Upvotes: 1

datUser
datUser

Reputation: 293

Not sure of the exact meaning of this error but my fix for this is to delete the node_modules directory and reinstall the required modules with npm install.

The above is a solution for this error showing up in a node project which uses locally installed modules. If there are some global modules that are throwing this error then you might have to reinstall those.

Upvotes: 3

Related Questions