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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With