I am using Electron module mdns and I am getting this error
A JavaScript error occurred in the main process
Uncaught Exception:
Error: Module version mismatch. Expected 49, got 48.
at Error (native)
at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:167:20)
at Object.Module._extensions..node (module.js:568:18)
at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:167:20)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/home/ingsaurabh/dp/node_modules/mdns/lib/dns_sd.js:24:20)
Uninstalled node module and reinstalled, but not working
npm rebuild --runtime=electron --target=1.3.4 --disturl=https://atom.io/download/atom-shell --abi=50
in your case it should be 49
Since mdns contains a native Node module you must rebuild it to target your version of Electron, there are a couple of ways to do this. I'd suggest using the electron-rebuild approach.
This is well-know problem when when upgrading node version. For example: 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 node version 6
So this is a general method apply for all javascript frameworks, not only electron ...
Related
Have upgraded our server from Ubuntu-18.04LTS to Ubuntu-20.04LTS After OS upgrade when I'm trying to start a nodejs application, but I get the below errors.
2021-11-14 10:48:01.641 - error: server-node-1: '[task-manager]
Error: The module \'/home/blruser/mibs/node_modules/weak/build/Release/weakref.node\'\nwas
compiled against a different Node.js version using\nNODE_MODULE_VERSION 57.
This version of Node.js requires\nNODE_MODULE_VERSION 64.
Please try re-compiling or re-installing\nthe module (for instance, using `npm rebuild` or `npm install`).\n at Object.Module._extensions..node (internal/modules/cjs/loader.js:807:18)\n at Module.load (internal/modules/cjs/loader.js:653:32)\n
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)\n
at Function.Module._load (internal/modules/cjs/loader.js:585:3)\n
at Module.require (internal/modules/cjs/loader.js:692:17)\n
at require (internal/modules/cjs/helpers.js:25:18)\n
at bindings (/home/blruser/mibs/node_modules/bindings/bindings.js:81:44)\n
at Object.<anonymous> (/home/blruser/mibs/node_modules/weak/lib/weak.js:7:35)\n
at Module._compile (internal/modules/cjs/loader.js:778:30)\n
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)\nWARN: uncaughtException be generated\n'
$ nodejs --version
v10.19.0
How do i re-compile without losing any existing application data? Please support. Thanks.
I'm not able to ask more info in comments. But have you tried deleting your node_modules directory and installing afresh using npm install or yarn install? This would not have any impact on your application data, rather just the node modules.
But if it's an electron project or similar, try running npm i -D electron-rebuild, following that do the above mentioned step.
I am following Cordova's Getting Started guide but I'm already stuck at the 2nd step. When I try to create my project by typing cordova create myApp, it fails with the following error message:
C:\Users\foobar\AppData\Roaming\npm\node_modules\cordova\node_modules\queue-microta
sk\index.js:5
? queueMicrotask.bind(globalThis)
^
ReferenceError: globalThis is not defined
at Object.<anonymous> (C:\Users\foobar\AppData\Roaming\npm\node_modules\cordova
\node_modules\queue-microtask\index.js:5:25)
at Module._compile (internal/modules/cjs/loader.js:816:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:827:10)
at Module.load (internal/modules/cjs/loader.js:685:32)
at Function.Module._load (internal/modules/cjs/loader.js:620:12)
at Module.require (internal/modules/cjs/loader.js:723:19)
at require (internal/modules/cjs/helpers.js:14:16)
at Object.<anonymous> (C:\Users\foobar\AppData\Roaming\npm\node_modules\cordova
\node_modules\run-parallel\index.js:4:24)
at Module._compile (internal/modules/cjs/loader.js:816:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:827:10)
I guess it's some sort of node or npm version problem. If possible though, I would rather not install a different version of node or npm, because I'm afraid it will break other projects otherwise. My node and npm versions are as follows:
node --version
v11.15.0
npm --version
6.7.0
Just make sure to reinstall the cordova if your node version changed.
And after that, cordova prepare again.
change Node version with Node Version Manager (NVM) to Node version10.X.X.
queueMicrotask don't work with Node version 11.X.X.
https://github.com/feross/queue-microtask/issues/13
I am trying to write a simple Electron app that uses Windows native notifications. For this use I depend on electron-windows-interactive-notifications.
When I run npm install and after that electron-rebuild on my project I get:
App threw an error during load
Error: The specified module could not be found.
\\?\C:\Users\moro\projects\tw-en-ty\node_modules\electron-windows-interactive-notifications\build\Release\notifications_bindings.node
at Error (native)
at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:173:20)
at Object.Module._extensions..node (module.js:583:18)
at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:173:20)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at bindings (C:\Users\moro\projects\tw-en-ty\node_modules\bindings\bindings.js:76:44)
According to a NodeJS issue it can be a native dependency problem. When I examine notifications_bindings.node by dependencywalker I see following missing direct DLLs (among many missing nested):
Frankly I have no idea what the problem is:
wrong usage of Electron?
wrong usage of electron-windows-interactive-notifications?
problem in NodeRT?
problem in node-gyp?
problem in my environment?
Can you help me move a step closer to the problem resolution?
Thank you very much!
Question was also asked here
Try following:
Install MS Visual Studio first.
npm install --global windows-build-tools run as Administrator
Run electron rebuild .\node_modules\.bin\electron-rebuild.cmd
Alternate method:
cd node_modules\electron-windows-interactive-notifications
node-gyp rebuild --target=1.8.4 --arch=x64 --dist-url=https://atom.io/download/electron where 1.8.4 is electron version
I've had this problem where, from a brand new installation of Node and npm, the serial port package won't load with the following error in the Hello World Electron package:
I am on Node version 6.6.0 and NPM version 3.10.7 and OS X 10.11.6.
I looked to see if I was somehow out of date, but looking at this list, I can't find anything that has a module version of 50. Is this a bug?
I have tried npm rebuild, as well as removing modules and reinstalling, but no dice.
Update: even though when I run node -v it prints v6.6.0, running process.versions.node in the web console gives me v6.5.0. What's going on here?
This is a known issue which is caused by the serialport module using native code that is built for a different version of Node. You can read a bit more about addons here, if you're interested; they're just modules written in C/C++ that can interface with Node so the module can interface with the hardware more easily.
The solution proposed by that issue is this:
npm rebuild --runtime=electron --target=1.2.5 --disturl=https://atom.io/download/atom-shell --build-from-source
If you've not already installed electron-rebuild, that might be helpful to ensure that the rebuilding process works correctly:
npm install --save-dev electron-rebuild
even though when I run node -v it prints v6.6.0, running process.versions.node in the web console gives me v6.5.0. What's going on here?
Electron uses its own version of Node that isn't connected to your system Node installation (see the homepage to view the Node version that the latest Electron uses, or use process.versions.node, like you did in the question).
You could try an older version (perhaps 1.1.0, which uses Chrome 50?) in case that is the cause of the issue.
In my case the error was:
App threw an error during load
Error: Module version mismatch. Expected 50, got 48.
at Error (native)
at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:173:20)
at Object.Module._extensions..node (module.js:583:18)
at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:173:20)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/myapp/node_modules/sqlite3/lib/sqlite3.js:4:15)
After rebuilding error was fixed:
npm install --save-dev electron-rebuild
npm rebuild --runtime=electron --target=1.4.3 --disturl=https://atom.io/download/atom-shell --build-from-source
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?
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.
I would try upgrading the module version that causes the issue on package.json.
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.