Alfo Alfo - 11 months ago 88
Node.js Question

Node Module Version Mismatch: Expected 50

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:

enter image description here

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
, running
in the web console gives me
. What's going on here?

Answer Source

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= --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).

You could try an older version (perhaps 1.1.0, which uses Chrome 50?) in case that is the cause of the issue.