Electron-builder: The module was compiled against a different Node.js version using NODE_MODULE_VERSION 51. This version of Node.js requires NODE_MODULE_VERSION 53.

Created on 10 Jul 2017  Â·  11Comments  Â·  Source: electron-userland/electron-builder


  • Version: 19.13.0

  • Target: darwin x64


develar at the Slack Channel told me to report this - as it seems to be a bug:

im trying to get my Electron Ionic App packaged - so i followed the Quickstart and got the following Error: The module was compiled against a different Node.js version using NODE_MODULE_VERSION 51. This version of Node.js requires NODE_MODULE_VERSION 53. (...).

after consulting your Slack Channel develar suggested to try it with env DEBUG=electron-builder*

and trying: "buildDependenciesFromSource": true, in m build property of package.json

with "buildDependenciesFromSource": true i saw it rebuilding serialport and it worked.

develar told me that this is still wrong behaviour and i should not need
"buildDependenciesFromSource": true
as he described to me:

this options makes sense only for prebuild and prebuild must fallback to build from sources if no suitable version.
in your case no fallback and it leads to runtime error.
prebuild installs incorrect version instead of correct/rebuilding. Why — not clear yet.

package.json with "buildDependenciesFromSource": true
Log of Successfull packaging with "buildDependenciesFromSource": true
Logs of Unsuccessfull build

i seem to be able to reproduce it when i delete my node_modules, then i use buildDependenciesFromSourceonce and do not delete my node_modules it keeps working (which makes sense to me)

backlog help wanted

Most helpful comment

On changing electron version you should always remove node-modules and install all dependencies again. On Windows I sometimes have to clear out the node-gyp cache/temp directory before everything will build again.

All 11 comments

You shouldn't usually need to use buildDependenciesFromSource.

If you just want to build any native modules which are npm dependencies, just add the following to your npm scripts:

    "postinstall": "electron-builder install-app-deps",

Yes, thats what i thought it says in the quick setup guide, so i added that line to my scripts in package json (see link to it in im original post).

But for some reason it did not help.

@timfish For some not yet unknown reasons prebuild fails to install correct version.

serialport uses ugly (sorry, but please do not use it, please use prebuild) node-pre-gyp instead of prebuild.

I guess electron-v54-* is missed and because node-pre-gyp is not so good as prebuild, rebuild from sources is not occurred.

I am sorry, but I don't have time to support node-pre-gyp. https://github.com/EmergingTechnologyAdvisors/node-serialport/issues/1180#issuecomment-314674524 Please ask node modules authors to use prebuild or just fork such module and fix it. if you are commercial company, you can donate and I will do something like https://github.com/atom/node-keytar/pull/67 for you.

Yes — my intention to not support node-pre-gyp and do not add any workarounds if some module still use it. It violates electron-builder project rules, but I hope it will make current strange and absurd situation more visible and in the end, all authors of native modules for Electron, will use prebuild and it will make Electron development more easy.

Ran into a this issue today on my project that uses electron-builder and node-serialport and was worried it would be a nightmare to track down.

Turns out it was as simple as updating my dependencies (as described at the end of this thread). node-serialport switched to prebuild in version 6.0.0 about three weeks ago. Now things are just working, without buildDependenciesFromSource or the postinstall install-app-deps step. Recording here for others who stumble upon this thread. Thanks @reconbot!

@islemaster Thanks for you post. I was having issues yesterday resolving this problem and your post got me on the right path.

I am developing an application on a raspberry pi using electron. My problem was that after updating my packages, it installed electron @v1.8.1. The application would run, and the builder would target 1.8.1 but for whatever reason, I would have an issue with serialport having a different node version. You can check the electron version by looking in node_modules/electron/dist/version.

To resolve the issue I reinstalled electron making sure to target version 1.7.9 and everything works great.

Again thanks to @islemaster @develar and @reconbot for making this possible.

On changing electron version you should always remove node-modules and install all dependencies again. On Windows I sometimes have to clear out the node-gyp cache/temp directory before everything will build again.

delete node_module and run npm i

Was this page helpful?
0 / 5 - 0 ratings