node-diskusage icon indicating copy to clipboard operation
node-diskusage copied to clipboard

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

Open zxfrank opened this issue 6 years ago • 10 comments

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?

zxfrank avatar Jun 06 '19 14:06 zxfrank

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.

chen-xin avatar Jun 11 '19 21:06 chen-xin

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 avatar Jun 11 '19 23:06 jduncanator

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

jduncanator avatar Jun 13 '19 23:06 jduncanator

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.

chen-xin avatar Jun 14 '19 16:06 chen-xin

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

jduncanator avatar Jun 17 '19 00:06 jduncanator

@jduncanator any update on that?

afshing avatar Aug 05 '19 21:08 afshing

Still broken it seems.

masudhossain avatar Nov 28 '19 05:11 masudhossain

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

i-break-codes avatar Mar 11 '20 07:03 i-break-codes

Broken for me on Node v12.18.1

Spaarw avatar Jun 30 '20 06:06 Spaarw