mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-02-03 21:25:13 +00:00
Node.js version error when using Native Module inside Electron Host Hook. #811
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @GitVTQ on GitHub (Jul 12, 2022).
Originally assigned to: @GregorBiswanger on GitHub.
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!
@GregorBiswanger commented on GitHub (Mar 28, 2023):
🎉🚀 New Electron.NET version 23.6.1 released 🚀🎉
With native Electron 23 and .NET 6 support. Your problem should be fixed here. If you continue to have the problem, please let us know. Please note the correct updating of your API & CLI. Info in the README. Have fun!