Problems with mdns and version mismatch in electron 1.3.1


#1

Hello,

I recently upgraded to electron 1.3.1, node 6.3.0 and npm 3.10.5.

We use the mdns 2.3.3 , everything installs fine with npm install (after i have rm -rf node_modules) but when I launch the app mdns fails with a message:

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> (/Users/thanpolas/Projects/work/xxx/xxx/node_modules/mdns/lib/dns_sd.js:25:20)

… and the stack goes on …

This issue has also been reported to the mdns package bug tracker

Any advice is welcome


#2

As per mdns’ author advice I got redirected to Electrons documentation about native modules: https://github.com/electron/electron/blob/master/docs/tutorial/using-native-node-modules.md

In there I noticed the ./node_modules/.bin/electron-rebuild command (which i couldn’t recall invoking in pre 1.x versions that i migrated from). Once I installed the electron-rebuild package and run the command the Electron application was able to move.

However, I have two critical problems now:

  1. Cannot run tests. In our usecase, Electron wraps around an existing Node.js application which we are not able to launch as standalone now because of another Module version mismatch. Which results in our whole existing test suite not being able to run because it cannot launch the node.js server in standalone mode.

  2. Cannot build electron application. We bundle the electron application using a grunt script which uses electron-packager and appdmg, this is a stand-alone grunt task module which when included by grunt it now throws a similar Module version mismatch error.

Both problems get solved by me doing an rm -rf node_modules;npm install but then I cannot start the Electron application in dev mode with npm start (which translates to node_modules/.bin/electron electron/main.js)

I’m a bit at a loss here, i’ve migrated from electron 0.x and all this is new to me.


#3

I am still stuck with this issue now at Electron version 1.4.7 and Node 6.5.0. I cannot run grunt as it breaks with the known version mismatch error…

Any help would be greatly appreciated.


#4

Ok i figured out the solution, the problem was that I run electron-rebuild on my working directory and this then could not run grunt or mocha

In retrospect the solution looks simple, yet, … The trick is to not run electron-rebuild on your working directory, rather add it in your buildflow and execute it right after you have copied your working directory in the staging folder that will get bundled. In my case that would be a git ignored folder build/app-copy on which then I will run electron-rebuild.

Worth noting that I tried running electron-rebuild on the electron-packager (grunt) task afterCopy hook, however the rebuilder broke with a gyp missing error…