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

Closed
opened 2026-01-29 16:49:15 +00:00 by claunia · 1 comment
Owner

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:

  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!

Originally created by @GitVTQ on GitHub (Jul 12, 2022). Originally assigned to: @GregorBiswanger on GitHub. <!-- Please search existing issues to avoid creating duplicates. --> This is a new issue. Could not find from existing issues with this subject. <!-- Which version of Electron.NET CLI and API are you using? --> <!-- Please always try to use latest version before report. --> 13.5.1 <!-- Which version of .NET Core and Node.js are you using (if applicable)? --> .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. <!-- What target are you building for? --> Windows 64 bit <!-- Enter your issue details below this comment. --> <!-- If you want, you can donate to increase issue priority (https://donorbox.org/electron-net) --> 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!
claunia added the bug label 2026-01-29 16:49:15 +00:00
Author
Owner

@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!

@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!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#811