Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compiling with wrong NODE_MODULE_VERSION ? #3660

Closed
emko opened this issue Feb 3, 2019 · 35 comments
Closed

compiling with wrong NODE_MODULE_VERSION ? #3660

emko opened this issue Feb 3, 2019 · 35 comments
Labels

Comments

@emko
Copy link

emko commented Feb 3, 2019

"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

@emko
Copy link
Author

emko commented Feb 3, 2019

ok it works fine with electron 4.0.0. , is it a issue with sqlite3, electron or electron-builder

@phhoef
Copy link

phhoef commented Feb 3, 2019

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?

@alexmoon
Copy link

alexmoon commented Feb 3, 2019

This is being caused by electron/electron#16687 in electron 4.0.4.

@phhoef
Copy link

phhoef commented Feb 4, 2019

@alexmoon thanks for your reply.
I am quite new to Node.js and Electron, so I am not sure if I understand the problem completely.

Electron is using the wrong version number for Node.js and that's why the native modules are not working any more?
Why is switching back to Electron 4.0.0 or 4.0.1 not a solution?

I also do not understand how to fix the problem?
Should I change the version number in the DEPS file of Electron?

@emko
Copy link
Author

emko commented Feb 4, 2019

@phhoef not sure what your issue is but 4.0.4 changes the NODE_MODULE_VERSION to 69 so any previous version works for me

@phhoef
Copy link

phhoef commented Feb 4, 2019

I deleted the node_modules folder in the project directory and issued yarn install --force.
Then I ran yarn build && electron-builder build -mw to build for macOS and Windows.
I got the NODE_MODULE_VERSION error on macOS and Windows.
Then I executed $(npm bin)/electron-builder install-app-debs
This command fails with a long error message.
I opened a new ticked explaining the problem in more detail - including the mentioned error message.
serialport/node-serialport#1793

@emko
Copy link
Author

emko commented Feb 4, 2019

@phhoef because you are still on 4.0.4 since NODE_MODULE_VERSION was changed to 69 in 4.0.4
electron/electron@9f0c410

@phhoef
Copy link

phhoef commented Feb 4, 2019

Thanks for your reply.
Sorry, I missed one important step in my description above.
After deleting the node_modules folder, I set the version number of electron in the package.json to 4.0.3: "electron": "^4.0.3"
Then I issued yarn install --force.

I would have expected, that this changes the version of Electron to 4.0.3, right?
Is this the wrong approach?
Do I have to change the node_version like shown in the linked commit?
I have looked in the electron folder below the node_modules, but I cannot find any file named DEPS?

@emko
Copy link
Author

emko commented Feb 4, 2019

not sure but for me i updated from 4.0.0 to 4.0.4 and i got this issue and the person said it was changed in 4.0.4 so i just reinstalled 4.0.0 and its working like before

@phhoef
Copy link

phhoef commented Feb 4, 2019

Hmm, seems that it does not work for me.
I tried to go back to Electron 4.0.0 with the mentioned procedure and still not working.
Which Node.js version are you using? Maybe that's the problem.
I am on 11.9.0

@emko
Copy link
Author

emko commented Feb 4, 2019

10.11.0

@phhoef
Copy link

phhoef commented Feb 4, 2019

I noticed, that the electron-builder is always using the latest electron version.

  • writing effective config file=release/builder-effective-config.yaml
  • rebuilding native production dependencies platform=darwin arch=x64
  • rebuilding native dependency name=fsevents
  • rebuilding native dependency name=@serialport/bindings
  • packaging       platform=darwin arch=x64 electron=4.0.4 appOutDir=release/mac

Is the electron version tightly bundled with the electron-builder version?

@phhoef
Copy link

phhoef commented Feb 4, 2019

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
Copy link

I am using sqlite3 and in my package.json my postinstall included

{
    "postinstall":"npx electron-rebuild -f -w sqlite3"
}

So after yarn install my application was working fine when I used to serve it using npm start & my npm start includes { "start": "electron ." } So electron-rebuild is able to rebuild the native dependencies properly!

But when I try to build the application using npx electron-builder --linux deb the it gives me the following error

The module /fakepath/node_modules/sqlite3/lib/binding/electron-v4.0-linux-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

So I think the issue doesn't lie with electron or the module (because works file when rebuilt using electron-rebuild) but with the electron-builder package. Can anyone else confirm this and post a solution? Is it a bug?

@emko
Copy link
Author

emko commented Feb 7, 2019

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

@thevirajshelke
Copy link

I was thinking of building it with electron-rebuild and instead of using electron-builder how about electron-packager? So let's try to build with electron-rebuild and package it with electron-packager. If it works fine we can definitely say the issue is with this package. I'll try to do this maybe today or tomorrow. If you are free can you try this and revert here? It would really help :)

@thevirajshelke
Copy link

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.

@Vuka951
Copy link

Vuka951 commented Feb 11, 2019

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)

@AdrianCuartas
Copy link

Thank you @thevirajshelke!
It worked for me.

ferranDelgado added a commit to ferranDelgado/electron-learning that referenced this issue Feb 12, 2019
Trying to add sqlite, but having issues with NODE_MODULE_VERSION

Issue found: electron-userland/electron-builder#3660
ferranDelgado added a commit to ferranDelgado/electron-learning that referenced this issue Feb 12, 2019
Trying to add sqlite, but having issues with NODE_MODULE_VERSION

Issue found: electron-userland/electron-builder#3660
ferranDelgado added a commit to ferranDelgado/electron-learning that referenced this issue Feb 12, 2019
Trying to add sqlite, but having issues with NODE_MODULE_VERSION

Issue found: electron-userland/electron-builder#3660
@ferranDelgado
Copy link

ferranDelgado commented Feb 12, 2019

I've tried to follow all of this thread and I couldn't make it work yet.
I'm working with/for windows 10 Node v10.15.0, I've set electron version to 4.0.3

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

I'm using electron-builder

electron-builder install-app-deps
  • electron-builder version=20.38.5
  • rebuilding native production dependencies platform=win32 arch=x64
  • rebuilding native dependency name=sqlite3

But still I get the same error, I guess I'm missing something

Thanks!

ferranDelgado added a commit to ferranDelgado/electron-learning that referenced this issue Feb 12, 2019
Trying to add sqlite, but having issues with NODE_MODULE_VERSION

Issue found: electron-userland/electron-builder#3660
@phhoef
Copy link

phhoef commented Feb 12, 2019

@ferranDelgado I guess, the way you specified the electron version is the problem - at least this was the problem for me.
^version “Compatible with version” according to the npm documentation.
I am a noob, but according to my understand, npm uses the latest compatible version. And as 4.0.4 is not a major release, it is compatible. That's why electron-builder is using electron 4.0.4 not 4.0.3.

See my last post.
You can either explicitly set the electronVersion for electron-builder or you can change the devDependency to "electron": "4.0.3". Removing the ^ uses exact the provided version.

Have a look here for the version syntax: https://docs.npmjs.com/files/package.json

@ferranDelgado
Copy link

@phhoef you are totally right, thanks!

@talamaska
Copy link

talamaska commented Feb 18, 2019

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.

@talamaska
Copy link

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

@thevirajshelke
Copy link

thevirajshelke commented Feb 20, 2019

"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 :)

@talamaska
Copy link

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

@yssmile
Copy link

yssmile commented Feb 22, 2019

hi , in my case I add this
"buildDependenciesFromSource":"true", see electron-builder
works find on MacOS but it failed on Windows(Virtual Box) when build

@ancodeUDW
Copy link

I had the same issue, and the only way to fix it was to go back from electron 4.0.5 to electron 4.0.3.

The problem was always with "sqlite3": "4.0.6", and so far I know, sqlite3 can't be compiled with the node version that is bundled with those electron versions.

However I did a windows.process.versions in both 4.0.3 and 4.0.5 and it states that
node: "10.11.0"
in both versions.

@sdkester
Copy link

FWIW, this is fixed for me in Electron v4.1.0 with node-abi v2.7.1 installed. The release notes from Electron say:

Electron 4.1.0 was released to work around issues users were experiencing with node-pre-gyp based native modules and our ABI number in Electron >= 4.0.4.

@anniee
Copy link

anniee commented Mar 26, 2019

For any other Macs, I had this same issue with a natively compiled module (keytar) since it compiled against my current node version, whereas electron installed via npm was compiled against a different one. Workaround by running ./node_modules/.bin/electron-rebuild to make the versions match and resolve this.

@tmirun
Copy link

tmirun commented Apr 1, 2019

i have same issue but ./node_modules/.bin/electron-rebuild cant resolve it, so i changed electron version to 4.0.3

@danni
Copy link

danni commented Jun 19, 2019

I'm having the same problem with Electron 5.0.x and node-abi 2.8. Everything seems to be building using 47, rather than 70 (which looks suspiciously like the node 5 ABI version...).

These were compiled with electron-builder install-app-deps on electron-builder 20.43.0.

@danni
Copy link

danni commented Jun 19, 2019

For reference, I tried flushing my node-gyp cache and node-modules and still had a problem. I did notice with DEBUG=* that it never seems to compile @serialport/bindings, which is one of the modules that complains. Interestingly this seems to work with Electron 4, possibly due to prebuilt?

This is interesting:

-rwxr-xr-x  1 danni  staff  201072 19 Jun 13:02 usb/build/Release/usb_bindings.node
-rwxr-xr-x  1 danni  staff  885752 19 Jun 13:02 iltorb/build/Release/iltorb.node
-rwxr-xr-x  1 danni  staff  55244 **28 Apr 00:58** @serialport/bindings/build/Release/bindings.node

@develar
Copy link
Member

develar commented Jun 24, 2019

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)

@m4heshd
Copy link

m4heshd commented Feb 21, 2021

"buildDependenciesFromSource":"true"

@develar this just worked perfectly. Although this config is being respected only when building. How come install-app-deps doesn't pick that up? It always downloads the prebuilt. And in my case (Electron 12) it downloads an incorrect version (v85) of the prebuilt even though I published the correct version. Is this because of node-abi reporting the incorrect ABI version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests