Node.js version error when using Native Module inside Electron Host Hook.
This is a new issue. Could not find from existing issues with this subject.
13.5.1
.NET 5.0
For Node.js, Initially I had 16.15.1 with NODE_MODULE_VERSION = 93 Downgraded to 15.14.0 with NODE_MODULE_VERSION = 88. Still get error.
Windows 64 bit
Steps to Reproduce:
-
Create an ASP.net Core web application and setup Electron.NET
-
Add Host Hook: electronize add hosthook
-
Inside the ElectronHostHook folder, Install native module usb-detection (https://github.com/MadLittleMods/node-usb-detection): npm install usb-detection
-
Inside the ElectronHostHook folder, Edit index.ts. Add code below to use usb-detection: import * as usbDetect from 'usb-detection'; ... onHostReady(): void { // execute your own JavaScript Host logic here usbDetect.startMonitoring(); usbDetect.find().then(function (devices) { console.log(devices); }).catch(function (err) { console.log(err); }); }
-
Inside ElectronHostHook folder, Install Electron for rebuilding: npm install --save-dev electron
-
Inside ElectronHostHook folder, Install Electron-Rebuild: npm i electron-rebuild --save-dev
-
Inside ElectronHostHook folder, rebuild: .\node_modules.bin\electron-rebuild.cmd
-
Start the application from the application folder: electronize start
-
Observer the error: ASP.NET Core Application connected... global.electronsocket ilQaBigpG0uKN1fXAAAA 2022-07-12T14:27:03.072Z The module '\?\C:\learn\electron\test\Test\Test\obj\Host\ElectronHostHook\node_modules\usb-detection\build\Release\detection.node' was compiled against a different Node.js version using NODE_MODULE_VERSION 88. This version of Node.js requires NODE_MODULE_VERSION 89. Please try re-compiling or re-installing the module (for instance, using
npm rebuildornpm install). stdout: BridgeConnector connected!
Originally I had Node.js 16.15.1, the error said ...was compiled against a different Node.js version using NODE_MODULE_VERSION 93. After downgrade Node.js to 15.14.9, it shows NODE_MODULE_VERSION 88.
I could not find a version of Node.js that has NODE_MODULE_VERSION 89 from https://nodejs.org/en/download/releases/.
Thank you very much for your help!