I'm building an Electron application that is expected to run on Ubuntu 20.xx Linux and a Raspberry Pi (Running Raspbian and arch=armv7l) and received the following error:
...was compiled against a different Node.js version using NODE_MODULE_VERSION 72.
This version of Node.js requires NODE_MODULE_VERSION 82.
I am using a variety of native modules that need to be (node-gyp) compiled to a particular architecture and I'm using mocha as my unit test suite.
I generally install node locally to a given project and that allows me to lock the versions of node and npm to whatever the project requires without too much fuss.
The Electron Native Module Documentation indicates that I should run electron-rebuild
after getting this version error.
Unfortunately this has 2 problems for me:
I need to rebuild all native binaries every time I go back and forth between tests and the application, which is unacceptable.
If I ever run
npm rebuild
, the next run ofelectron-rebuild
exits successfully without rebuilding anything (presumably due to an invalid cache hit).
NOTE: To work around #2, I'm able to proceed with this incantation:
rm -rf node_modules
npm install
electron-rebuild
I've learned some things while investigating this error:
The mysterious NODE_MODULE_VERSION value (82 vs 73 in this case) can (ostensibly) be found and matched to a node semver version here: https://nodejs.org/en/download/releases/
Logging
process.version
for the current version of Electron (v10.1.5) indicates the following:
Launching Electron with:
{
node: '12.16.3',
v8: '8.5.210.26-electron.0',
uv: '1.34.2',
zlib: '1.2.11',
brotli: '1.0.7',
ares: '1.16.0',
modules: '82',
nghttp2: '1.41.0',
napi: '5',
llhttp: '2.0.4',
http_parser: '2.9.3',
openssl: '1.1.0',
icu: '67.1',
unicode: '13.0',
electron: '10.1.5',
chrome: '85.0.4183.121'
}
- The release info for Node version 12.16.3 (which I have installed) indicate NODE_MODULE_VERSION 72, not 82.
- NODE_MODULE_VERSION 82 does not appear in any node releases (that I see).
- Electron Native Module Docs also indicate that I can use npm directly if I set a relatively large collection of environment variables in order to build binaries. When I attempt this, the build fails with,
Failed at the lzma-native@6.0.1 install script
.
In summary, I would like to install whatever is necessary, so that my local native node & npm binaries are compatible across the Electron runtime and my shell environment and work in both without being rebuilt.
Ah, but how?
Update:
FWIW, node-hid has been rewritten for newer versions of node/Electron, so I'm now running Electron v11.0.3 and node-hid v2.0.0-0.