Electron.NET icon indicating copy to clipboard operation
Electron.NET copied to clipboard

Node.js version error when using Native Module inside Electron Host Hook.

Open GitVTQ opened this issue 3 years ago • 0 comments

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:

  1. Create an ASP.net Core web application and setup Electron.NET

  2. Add Host Hook: electronize add hosthook

  3. Inside the ElectronHostHook folder, Install native module usb-detection (https://github.com/MadLittleMods/node-usb-detection): npm install usb-detection

  4. 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); }); }

  5. Inside ElectronHostHook folder, Install Electron for rebuilding: npm install --save-dev electron

  6. Inside ElectronHostHook folder, Install Electron-Rebuild: npm i electron-rebuild --save-dev

  7. Inside ElectronHostHook folder, rebuild: .\node_modules.bin\electron-rebuild.cmd

  8. Start the application from the application folder: electronize start

  9. 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 rebuild or npm 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!

GitVTQ avatar Jul 12 '22 14:07 GitVTQ