Nodejs Module version mismatch. Expected 11, got 1 - node.js

after updating NodeJS to v0.10.29 I got the following 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 bindings (/home/masiar/usi_liquid_streams/node_modules/jsdom/node_modules/contextify/node_modules/bindings/bindings.js:76:44)
at Object.<anonymous> (/home/masiar/usi_liquid_streams/node_modules/jsdom/node_modules/contextify/lib/contextify.js:1:96)
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)
Executing sudo npm update did not work. I installed back version v0.10.15 (was using that one before), ran sudo npm update and uninstalled and installed back jsdom gave the same error.

This problem is usually happened when upgrading node version. You are in this 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. Libraries will be compiled again with new node version
Hope this help :)

Related

Always same Type Error occuring when using npm

I always receive the same error when using npm, e.g. npm init
/usr/local/lib/node_modules/npm/lib/utils/unsupported.js:3
var supported = require('../../package.json').engines.node
^
TypeError: Cannot read property 'node' of undefined
at Object.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/unsupported.js:3:54)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at /usr/local/lib/node_modules/npm/bin/npm-cli.js:19:21
at Object.<anonymous> (/usr/local/lib/node_modules/npm/bin/npm-cli.js:155:3)
I tried reinstalling, but it didn't solve the problem.
Can someone help me please?
It looks like you are running recent npm code with an old package.json for your npm installation. That's odd. (Maybe you started doing an npm upgrade and canceled it halfway through?)
If I'm right about this, running this code from your command line should return an old npm version number:
node -p 'require("/usr/local/lib/node_modules/npm/package.json").version'
Then get your version of node with node -v. Odds are good that there is
If you're npm is less than version 6 or your node is less than version 12, you will probably want to uninstall Node.js and npm, and then reinstalling Node.js (which will reinstall npm).
If your version of npm is not before version 6, then your npm executable is somehow reading a version of the package.json that isn't that version. Check for symlink shenanigans by running:
node -p 'require("/usr/local/lib/node_modules/npm/lib/utils/../../package.json`).version"
If that doesn't return the same version as the first command above, you'll probably want to uninstall Node.js and npm, remove all of /usr/local/lib/node_modules/npm if the uninstall didn't remove it, and then reinstall Node.js.

"I got an error after reinstalling nodejs"

node:internal/modules/cjs/loader:1161 return process.dlopen(module,
path.toNamespacedPath(filename));
^
Error: The module '\?\G:\Discord
bot\Bot\ZackyBot\node_modules\canvas\build\Release\canvas.node' was
compiled against a different Node.js version using NODE_MODULE_VERSION
83. This version of Node.js requires NODE_MODULE_VERSION 88. Please try re-compiling or re-installing the module (for instance, using npm rebuild or npm install).
at Object.Module._extensions..node (node:internal/modules/cjs/loader:1161:18)
at Module.load (node:internal/modules/cjs/loader:967:32)
at Function.Module._load (node:internal/modules/cjs/loader:807:14)
at Module.require (node:internal/modules/cjs/loader:991:19)
at require (node:internal/modules/cjs/helpers:92:18)
at Object. (G:\Discord bot\Bot\ZackyBot\node_modules\canvas\lib\bindings.js:3:18)
at Module._compile (node:internal/modules/cjs/loader:1102:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1131:10)
at Module.load (node:internal/modules/cjs/loader:967:32)
at Function.Module._load (node:internal/modules/cjs/loader:807:14)
at Module.require (node:internal/modules/cjs/loader:991:19)
at require (node:internal/modules/cjs/helpers:92:18)
at Object. (G:\Discord bot\Bot\ZackyBot\node_modules\canvas\lib\canvas.js:9:18)
at Module._compile (node:internal/modules/cjs/loader:1102:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1131:10)
at Module.load (node:internal/modules/cjs/loader:967:32) { code: 'ERR_DLOPEN_FAILED' }
It seems like you installed a newer version of NodeJS than earlier. But you did not compile your project ZackyBot's node modules using the current version of the NodeJS you installed.
I would suggest you go to your project directory and clean all your node modules. Then reinstall them again. Follow the steps below:
Delete node_modules directory inside ZackyBot directory
Execute npm install command on a terminal from ZackyBot directory
Since you updated your nodeJS version to a newer one, you need to update your canvas too.
run npm install canvas and you should be good to go.
This might be due to improper installation of node modules and can occur due to poor network conditions.
Solved this issue by deleting the nodemodules folder and doing a clean installation of node modules files by running "npm install".

NPM dead after update - cannot find module (OSX)

Just did a minor npm update to the latest version (I can't remember what it was as npm no longer works - hence the question) but I think my installed version before the update was 5.6.0. That could be wrong though.
Anyway after running...
sudo npm install -g npm
... npm no longer works at all. Anything I do results in :
internal/modules/cjs/loader.js:596
throw err;
^
Error: Cannot find module './auth.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:594:15)
at Function.Module._load (internal/modules/cjs/loader.js:520:25)
at Module.require (internal/modules/cjs/loader.js:650:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-registry-fetch/index.js:7:17)
at Module._compile (internal/modules/cjs/loader.js:702:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
at Module.load (internal/modules/cjs/loader.js:612:32)
at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
at Function.Module._load (internal/modules/cjs/loader.js:543:3)
Any suggestions?
After trying a few different things including reinstalling node via brew the only thing that worked was to download and run the node installer binary from the node site.
Hope it helps somebody else.
I fixed this issue this way:
yarn global add npm

NPM Cannot find module 'balanced-match'

Any command I'm try to run with npm I get:
module.js:340
throw err;
^
Error: Cannot find module 'balanced-match'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/glob/node_modules/minimatch/ node_modules/brace-expansion/index.js:2:16)
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)
Including when I try to npm install -g balanced-match
I know this is very old, and I hope that you found your answer, but for future questors:
I saw this issue recently when I tried to use npm after upgrading node to a newer version with n.
If you recently moved to a newer version of node, and you experience the error mentioned above, you may fix it by installing the latest version of npm. As this may not be possible, because npm is used to update itself, and npm is obviously not working:
Downgrade back to an earlier version of node where your copy of npm worked.
Update npm: sudo npm install npm#latest -g
Upgrade back to the version of node you were using before.
If that doesn't work, or you think it will be easier anyway, you may have to reinstall npm from binary.
If you haven't changed versions of node recently, you may need to reinstall node, or at least npm, from their websites.
I can suggest you the following link which suggest how to install
npm balanced-match
https://www.npmjs.com/package/balanced-match
or download from
github.com/juliangruber/balanced-match

Install node-expat on ubuntu or centos

I'm trying to install node-expat. I've tried everything suggested that I could find. I don't get any build errors while running npm install node-expat. I've put in all the dependencies & building kits, tried npm cache clean & tried it on both CentOS (Amazon Linux) and Ubuntu 12.10 but the error remains the same:
module.js:485
process.dlopen(filename, module.exports);
^
Error: Module version mismatch, refusing to load.
at Object.Module._extensions..node (module.js:485:11)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at Object.<anonymous> (/home/ubuntu/cc/node_modules/node-expat/lib/node-expat.js:4:13)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
How can I get it to run without hitches?
The reason I want node-expat is for node-xmpp
This may or may not help you, but I was getting the same error with an appjs app I'm working on, and I just figured out what was causing it for me. I have node v0.10.x installed on my machine, but I was building the modules to include them in an appjs app (which currently comes packaged with v0.8.x of node.exe. So I was building the module with 0.10, but trying to run it on 0.8.
I uninstalled my node 0.10, installed 0.8, rebuilt/installed the offending module into my appjs app, and the error went away. So make sure you're building the module with the same version of node you're trying to run it on!

Resources