2

I'm getting a "Module version mismatch error" when I try to use a headless browser with a desktop Node shell. I've tried Zombiejs and Phantomjs with both nw.js and atom-shell; in both cases as soon as the headless browser comes into play the application crashes with a module mismatch error.

Here's the error with Phantomjs and atom-shell:

Uncaught Exception:
Error: Module version mismatch. Expected 41, got 14.
    at Error (native)
    at Object.module.(anonymous function) (ATOM_SHELL_ASAR.js:118:20)
    at Object.module.(anonymous function) [as .node] (ATOM_SHELL_ASAR.js:118:20)
    at Module.load (module.js:370:32)
    at Function.Module._load (module.js:325:12)
    at Module.require (module.js:380:17)
    at require (module.js:399:17)
    at bindings (/Users/Ajay/Projects/atom-shell/node_modules/phantom/node_modules/dnode/node_modules/weak/node_modules/bindings/bindings.js:76:44)
    at Object.<anonymous> (/Users/Ajay/Projects/atom-shell/node_modules/phantom/node_modules/dnode/node_modules/weak/lib/weak.js:7:35)
    at Module._compile (module.js:475:26)

Any idea what's causing the error?

1
  • Try running script/bootstrap => script/build on your console... does it help?
    – kenju
    Commented Sep 10, 2015 at 13:30

1 Answer 1

6

The error is thrown from Node.js internals. You are mixing binary modules built for different versions of io.js or Node.js. The module version refers to the C++ NODE_MODULE_VERSION macro, which is accessible in JavaScript as process.versions.modules.

14 seems to be the version number for Node.js since Node.js v0.11.11.

I can't find any information on 41, although it is clear that 42 is the version number used by io.js v1.0.0.

UPDATE: 41 is the version of io.js bundled in atom-shell internally, which is cut from io.js v1.0.0-pre.

nw.js/atom-shell is using its own copy of Node.js to execute the engine. In a terminal, try doing a clean installation and execution without going to atom-shell.

Also note that this problem should not be exclusive to Phantom.js or Zombie.js, but to all modules using C++ code.

To solve this problem, use one of the following instructions:

  • atom-shell offers a tutorial for using native modules.
  • nw.js also has a tutorial
4
  • I have tried the code without atom shell or nwjs and it works well. Was wondering if there's a way to run them both?
    – apparatix
    Commented Feb 28, 2015 at 14:33
  • Ah, finally found where the 41 came from. Answer updated. @apparatix I don't use atom-shell or nw.js, but basically you either need to use the same Node.js version when installing the module as nw.js/atom-shell is using, or install a module from nw.js/atom-shell. For example, atom-shell has a custom apm command designed just for this kind of purposes.
    – Timothy Gu
    Commented Feb 28, 2015 at 18:39
  • I got Module version mismatch. Expected 46, got 14. What does it mean?
    – hellboy
    Commented Nov 25, 2015 at 7:28
  • @hellboy similar situation: you are using node.js 0.12 (or 0.11) to install the native module but you are using atom-shell. Use apm to install the module.
    – Timothy Gu
    Commented Nov 25, 2015 at 17:17

Not the answer you're looking for? Browse other questions tagged or ask your own question.