August
August

Reputation: 1819

Electron: __ was compiled against a different version of Node.js

When trying to package electron app on macOS Sierra using electron-installer-dmg, I get the following:

Error: The module '/Users/august/projects/node_modules/macos-alias/build/Release/volume.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 54. This version of Node.js requires
NODE_MODULE_VERSION 57. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
at Object.Module._extensions..node (module.js:598:18)<br>
at Module.load (module.js:503:32)<br>
at tryModuleLoad (module.js:466:12)<br>
at Function.Module._load (module.js:458:3)<br>
at Module.require (module.js:513:17)<br>
at require (internal/module.js:11:18)<br>
at Object.<anonymous> (/Users/august/projects/node_modules/macos-alias/lib/create.js:7:13)<br>
at Module._compile (module.js:569:30)<br>
at Object.Module._extensions..js (module.js:580:10)<br>
at Module.load (module.js:503:32)<br>

Versions:

Node 8.0.0
npm: 5.4
electron: 1.7.5
electron-installer-dmg: 0.2.1
electron-packager: 8.7.2
macos-alias: 0

I've tried:

Is there any solution to this problem?

Upvotes: 2

Views: 2957

Answers (2)

Long Nguyen
Long Nguyen

Reputation: 10994

If you are using electron-builder to build your electron project. You need to run this command electron-builder install-app-deps

Add this command into scripts of package.json to ensure your native dependencies are always matched electron version.

{
    "scripts": {
       "postinstall": "electron-builder install-app-deps",
    }
}

Upvotes: 0

Sotiris Kiritsis
Sotiris Kiritsis

Reputation: 3346

Electron 1.7.5 uses:

  • Node: 7.9.0
  • Chromium: 58.0.3029.110
  • V8: 5.8.283.38

Only packages compiled with the same version of Node will work. Try downgrading your Node version to 7.9 (you can find the installer here) and try the whole process from the start.

Upvotes: 1

Related Questions