electron-johnny-five-examples icon indicating copy to clipboard operation
electron-johnny-five-examples copied to clipboard

"Uncaught Error: Module version mismatch." in bindings.js

Open troywarr opened this issue 8 years ago • 11 comments

I'm stuck on an error in the Electron Console that's preventing the 1-led script from reaching the point of communicating with my Arduino board (a Mega 2560).

I'm running:

  • OS X El Capitan v10.11.5
  • Node v6.2.2
  • npm v3.9.5
  • Arduino IDE v1.6.9

These are the steps I've followed:

  1. connect Arduino to computer via USB, and connect a LED as shown
  2. in Arduino IDE, verify that Board is Arduino/Genuino Mega or Mega 2560
  3. verify that Processor is ATmega2560 (Mega 2560)
  4. verify that Port is /dev/cu.usbmodem1421 (Arduino/Genuino Mega or Mega 2560)
  5. verify that Programmer is AVRISP mkII
  6. open File > Examples > Firmata > StandardFirmata
  7. upload to Arduino
  8. close Arduino IDE
  9. in terminal, git clone [email protected]:sofroniewn/electron-johnny-five-examples.git
  10. cd electron-johnny-five-examples/1-led/
  11. npm install
  12. ./node_modules/.bin/electron-rebuild
  13. npm start

At this point, the Electron app starts and opens a new window. The "Click me!" button is initially disabled, but it never becomes enabled. If I open Developer Tools, I see this error in the Console:

/Users/twarr/electron-johnny-five-examples/1-led/node_modules/bindings/bindings.js:83 Uncaught Error: Module version mismatch. Expected 47, got 48.

I did some Googling and it appears that this can happen if a package is installed with one version of Node, then another version is later installed:

http://stackoverflow.com/questions/15584529/module-version-mismatch-expected-11-got-1

That didn't happen in my case, but I tried the recommended solution anyways:

rm -rf node_modules; npm update

That results in:

npm WARN prefer global [email protected] should be installed with -g

> [email protected] install /Users/twarr/electron-johnny-five-examples/1-led/node_modules/nslog
> node-gyp rebuild

  CXX(target) Release/obj.target/nslog/src/main.o
  CXX(target) Release/obj.target/nslog/src/nslog_mac.o
  SOLINK_MODULE(target) Release/nslog.node

> [email protected] install /Users/twarr/electron-johnny-five-examples/1-led/node_modules/serialport
> node-pre-gyp install --fallback-to-build

[serialport] Success: "/Users/twarr/electron-johnny-five-examples/1-led/node_modules/serialport/build/Release/serialport.node" is installed via remote

> [email protected] postinstall /Users/twarr/electron-johnny-five-examples/1-led/node_modules/electron-prebuilt
> node install.js

[email protected] /Users/twarr/electron-johnny-five-examples/1-led
├── [email protected]
├── [email protected]
└── [email protected]

However, that doesn't appear to have any effect; running npm start again, I still see the same error in the Electron Console.

While this issue doesn't appear to be unique to this repo (it seems to be a general Node issue that can occur under a variety of circumstances), it does happen (at least for me) after following all instructions in the 1-led example exactly, so I'm hoping it's something you've encountered or are familiar with.

Please let me know if you have any troubleshooting ideas, or if you need me to provide any more details. I'm not sure how to proceed. Thanks!

troywarr avatar Jun 17 '16 19:06 troywarr

It looks like this might have something to do with Node v6.x. I installed nvm and downgraded to Node v5.11.1, and now it's working fine!

troywarr avatar Jun 17 '16 22:06 troywarr

@troywarr I can confirm that using node 5.11.1 fixed that error, interestingly.

However, for testing I tried to use a more recent electron-prebuilt version, as well. Anything 1.0+ throws the same error (after having to modify main.js a bit to comply to the new API):

/Users/tom/gits/electron-johnny-five-examples/1-led/node_modules/bindings/bindings.js:83 Uncaught Error: Module version mismatch. Expected 48, got 47.

Version 0.37.8, the one before the 1.0 version bump works just fine though. Any idea why that is happening? I'd like to use more recent electron versions.

nylki avatar Jun 22 '16 14:06 nylki

I can confirm this issue in Linux, it appears to be related to paths, I guess the solution is to refactor the entire code piece by piece to see what is going on.

This is my error.

/home/user/electronj5/1-led/node_modules/johnny-five/node_modules/serialport/node_modules/bindings/…:83 Uncaught Error: Module version mismatch. Expected 47, got 46.

I downgraded to node 4.00 and it didn't worked, node v5.11.1 works out of the box, this is then an error associated to a dependency of original build of the app. I'm intrigued....

Regards.

calugo avatar Jul 31 '16 23:07 calugo

Hi all,

I have the same problem:

Error: Module version mismatch. Expected 49, got 48. at Error (native) at process.module.(anonymous function) as dlopen at Object.Module._extensions..node (module.js:568:18) at Object.module.(anonymous function) as .node 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 bindings /Projects/ElectronDevice/node_modules/bindings/bindings.js:76:44)

npm latest node latest johnny-five latest "electron-prebuilt": "^1.3.1" OS ubuntu

I was looking for this issue on all over the net, but nothing resolves this... was trying all combinations of the npm, node and johnny-five but, I guess didn't find right combination...

any idea ?

Sparo avatar Aug 01 '16 09:08 Sparo

Yes, as the others said before just make sure you are using the same node version (5.11.1) and the standard instructions and it will work, now for a definitive solution a full step by step rebuilt of the project seems to be in order so all the dependencies are in accordance to your setup.

I will try that soon and will post the results here.

calugo avatar Aug 01 '16 22:08 calugo

Tried installing node 5.11.1 and then rm -rf node_modules then npm installeven installed electron-rebuild and done ./node_modules/.bin/electron-rebuild... but error still persist... I am so frustrated, doing this almost 30 hours... but nothing helps ... so far...

Sparo avatar Aug 01 '16 23:08 Sparo

Did you sourced your node version?

calugo avatar Aug 02 '16 09:08 calugo

you can use this. https://github.com/tj/n

Basically, after you install your node version and run node -v to check which version is actually running then using n (link above) you can change the version to the want you want (after that you can run node -v to verify this is the case) Once you have done that, remove, rebuild as you just did and it must work! (That is what I did) Im running node in ubuntu 14 LTS but for mac should be the same.

calugo avatar Aug 02 '16 09:08 calugo

sudo npm cache clean -f Here we go sudo npm install -g n sudo n "version" sudo ln -sf /usr/local/n/versions/node/<VERSION>/bin/node /usr/bin/node

then rebuild and re run!

calugo avatar Aug 02 '16 09:08 calugo

I have struggle with this some time now, and the problem was in electron version. Your solution was working perfectly for this version combination of electron and johnny-five.

this was my package.json:

{ "name": "JumpDevice", "version": "1.0.0", "description": "Mesuring jump distance", "main": "app.js", "dependencies": {}, "devDependencies": { "electron-prebuilt": "^1.3.1", "electron-rebuild": "^1.1.5", "johnny-five": "^0.9.61" }, "scripts": { "test": "echo "Error: no test specified" && exit 1", "start": "electron .", "clean": "rm -rf node_modules && npm install" }, "repository": { "type": "git", "url": "git+ssh://[email protected]/Sparo/electrondevice.git" }, "keywords": [ "Jump", "mesuring", "ultrasound" ], "author": "Nenad Sparic", "license": "ISC", "homepage": "https://bitbucket.org/Sparo/electrondevice#readme" }

and now package.json is

{ "name": "JumpDevice", "version": "1.0.0", "description": "Mesuring jump distance", "main": "app.js", "dependencies": { "electron-prebuilt": "^0.36.7", "johnny-five": "^0.9.23" }, "devDependencies": { "electron-rebuild": "^1.1.3" }, "scripts": { "test": "echo "Error: no test specified" && exit 1", "start": "electron .", "clean": "rm -rf node_modules && npm cache clean -f && npm install" }, "repository": { "type": "git", "url": "git+ssh://[email protected]/Sparo/electrondevice.git" }, "keywords": [ "Jump", "mesuring", "ultrasound" ], "author": "Nenad Sparic", "license": "ISC", "homepage": "https://bitbucket.org/Sparo/electrondevice#readme" }

I hope there will be a moment that I could go into the newer version of electron...definitely, this is a super tool for cross-OS application.

Sparo avatar Aug 04 '16 10:08 Sparo

The issue here isn't related to johnny-five, the main problem comes from node-serialport. You will find some workarounds here: https://github.com/EmergingTechnologyAdvisors/node-serialport/issues/538

nlemoine avatar Oct 15 '16 09:10 nlemoine