electron-builder: compiling with wrong NODE_MODULE_VERSION ?

“electron-builder”: “^20.38.5”,

Windows

I can’t figure this out

node_modules\sqlite3\lib\binding\electron-v4.0-win32-x64\node_sqlite3.node' was compiled against a different Node.js version using NODE_MODULE_VERSION 64. This version of Node.js requires NODE_MODULE_VERSION 69. Please try re-compiling or re-installing the module (for instance, using npm rebuildornpm install).

what is NODE_MODULE_VERSION 69 anyways? electron is 4.0.4 everything else build fines just sqlite3 anyone know how what i can do to fix this? i tested it out with electron-rebuild as whats on the electronjs website and that builds it fine and the electron app works but when i try to build with electron-builder i get that error.

Thanks

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 21
  • Comments: 35 (1 by maintainers)

Commits related to this issue

Most upvoted comments

I have checked building the app with following versions and the build is successful

{
    "dependencies": {
        "sqlite3": "^4.0.6"
     },
    "devDependencies": {
        "electron": "4.0.3",
        "electron-builder": "^20.38.5",
        "electron-rebuild": "^1.8.4",
    }
}

So you can keep everything at its latest version just keep electron at 4.0.3 and your app should build fine! The issue has something to do with specific version of electron i.e. 4.0.4 and electron-builder.

"scripts": {
        "start": "electron .",
        "postinstall": "npx electron-rebuild -f -w sqlite3",
        "build-linux-deb": "npx electron-builder --linux deb"
},
"build": {
        "npmRebuild": "false"
},
"dependencies": {
        "sqlite3": "^4.0.6"
},
"devDependencies": {
        "electron": "^4.0.5",
        "electron-builder": "^20.38.5",
        "electron-rebuild": "^1.8.4",
}

This also works fine for me!

So you can keep everything updated & just in the build key inside your package.json add npmRebuild:false, make sure that your postinstall contains rebuild command. This will rebuild all the dependencies immediately after downloading packages and when you build your app using electron-builder it won’t rebuild again because npmRebuild is set to false.

The issue is with electron-builder, when it tries to rebuild packages while building app it fails!
So you can either use this comment of mine or this one 😃

I am sure devs will fix this asap till then these are the workarounds 😃

It is not electron-builder problem.

electron-rebuild works only because it does rebuild, but electron-builder install-app-deps doesn’t even try to build your module using some custom solution — all what electron-builder does, — calls appropriate tool (https://www.npmjs.com/package/prebuild or whatever is used by module author) with a proper environment.

If native module doesn’t use any prebuild — then no problem regardless of ABI/electron version. Module will be recompiled on your machine.

If native module uses prebuild or any other such tool to provide prebuilts — then if Electron violates semver policy or for some another reason such tool is not aware about new Electron ABI, you will get such problem (well, it is definitely not expected for prebuild that changing of patch version will increment ABI version).

So, electron-builder cannot handle such errors — we rely on existing tools and I don’t want to reinvent prebuild or incorporate some hacks. Or Electron should be fixed itself, or prebuild (and if error on Electron side and Electron maintainers don’t want to fix it, then some workaround on prebuild side).

I hope that now situation and reasons are clear for everyone.

So, if Electron violates semver policy once again and for now no workaround on prebuild side, then workaround is simple — just force rebuild using configuration option:

"buildDependenciesFromSource":"true"

(you can also pass as CLI arg: -c.buildDependenciesFromSource=true)

Same issue here with serialport. Running electron-rebuild and/or electron-builder install-app-deps does not work. Even switching back to older electron (4.0.0, 4.0.1) version does not help. Also tried newer and older versions of serialport. Still no success. Any ideas?

Thank you @thevirajshelke! It worked for me.

I explicitly set the electronVersion of the electron-builder to 4.0.3 and indeed, it is working again on macOS and Windows.

Thanks for your help

@thevirajshelke This is exactly what I have done as workaround.

So according to Electron maintainers - electron-builder should do something in order to fix the issue with building the native deps.

Yes but that’s not a solution. I didn’t understand the reasoning about switching to non existant node version, specific for electron and its ABI stuff that i don’t understand. When I set npmRebuild to false and perform the sqlite rebuild with electron-rebuild - everything is fine. So the issue must be in that npm rebuild command that electron-builder perform, which breaks sqlite module build.

@phhoef you are totally right, thanks!

Have the same issue after packaging with sqlite3. (stayed on 4.0.3 and all works fine. Hope a solution is found for 4.0.4 soon)

yea like i said mine builds fine with rebuilder and i don’t how to fix it when i use builder