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

was compiled against a different Node.js version 64 vs 72 #41

Open
zxfrank opened this issue Jun 6, 2019 · 10 comments
Open

was compiled against a different Node.js version 64 vs 72 #41

zxfrank opened this issue Jun 6, 2019 · 10 comments
Assignees
Labels

Comments

@zxfrank
Copy link

zxfrank commented Jun 6, 2019

Hello, I got this issue this morning after installing...

'.../node_modules/diskusage/build/Release/diskusage.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 64. This version of Node.js requires
NODE_MODULE_VERSION 72. Please try re-compiling or re-installing
the module (for instance, using npm rebuild or npm install).

node version 10.16.0
npm version 6.9.0
node-gyp version 4.0.0

anyone having this issue?

@chen-xin
Copy link

chen-xin commented Jun 11, 2019

I have exact the same issue in an Electron 5.0 project. In my condition, the postinstall script calls electron-builder to rebuilds binarys for electron, when I try to test this function without electron, the error occurs.

You can run npm rebuild diskusage to build binary for node 10, if what you actually need is to use this package in electron, do postinstall again. The following monkey patch to local diskusage's index.js works with both electron and nodejs for me:

var native = process.versions['electron'] ?
  require("./build/Release/diskusage.node") :
  require(`./lib/win32-${process.arch}/diskusage.node`) ;

NOTE: Needs to run npm rebuild diskusage then copy the generated diskusage.node to './lib/win32-x64'.

@jduncanator pls add multi target binary feature like sqlite3 do, which will generate binary in 'electron-v5.0-win32-x64' and 'node-v64-win32-x64', then we don't have to care about platforms.

@jduncanator
Copy link
Owner

I'll take a look into this problem. Be aware that diskusage targets multiple platforms, so using the provided "mokey patch" to index.js will only resolve the problem when running on Windows. I'll investigate a more cross platform friendly fix.

@jduncanator jduncanator self-assigned this Jun 11, 2019
@jduncanator
Copy link
Owner

I'm still not sure exactly what steps reproduce this issue. Can you provide some more information into how you ran into this?

@chen-xin
Copy link

Thank you for concerning about this issue. I reproduced it with a clean new vue-electron project, here are the steps:

  1. Create a fresh vue-electron project as this guid. This will add a postisntall script to package.json, which will rebuild electron's native module after any new module installed.
  2. yarn add diskusage. After diskusage sucessfully downloaded, the postinstall script rebuilds it to electorn's native module, somehow with another nodejs version provided by electron.
  3. Now I can use diskusage in the electorn app, but if I create some unit tests that runs under operation system's nodejs instead of electorn, the issue occurs, because the binary file diskusage.node was rebuilt for electron's own use.

Here is my test project which reproduces the issue:

diskusage-issue1.zip

The sqlite3 module provides a example for resolving this, it keeps native modules for both os and electron, and auto select them in runtime.

@jduncanator
Copy link
Owner

Great, thank you for the detailed steps. I'll take a look at this today and hopefully push a fix!

@afshing
Copy link

afshing commented Aug 5, 2019

@jduncanator any update on that?

@masudhossain
Copy link

Still broken it seems.

@i-break-codes
Copy link

Broken for me on node 13.0.1.. need to search for some other package

@Spaarw
Copy link

Spaarw commented Jun 30, 2020

Broken for me on Node v12.18.1

@ashen114
Copy link

npm i -g electron-rebuild
electron-rebuild

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

8 participants