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?
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 asprocess.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: