Error with executable of electron-builder; cannot find module '@socket.io/component-emitter' #953

Closed
opened 2026-01-29 16:52:40 +00:00 by claunia · 3 comments
Owner

Originally created by @Thokerb on GitHub (Jun 5, 2024).

ElectronNET.CLI Version: 23.6.2.0

  • Version:

.Net 6
Node.JS v18.18.2

  • Target:
    electronize build /target win

When building the project with target win as portable and then trying to run it, the following error message is appearing.
There are no errors during building the application.
cannot find module '@socket.io/component-emitter'
After inspecting the created app.asar archive, the package is included.
When running electronize start, then the app is starting without problems.

Steps to Reproduce:

  1. Run electronize build /target win
  2. Try to start the portable executable
  3. Error message cannot find module '@socket.io/component-emitter' appears

Reason:

This is related to the issue https://github.com/electron-userland/electron-builder/issues/8244 . I don't know the exact problem of the new electron-builder, but when switching back to version 24.13.3 of the electron-builder the application can start after building.

Intermediate solution:

Set electron-builder version to 24.13.3 locally

npm install -g electron-builder@24.13.3
npm link electron-builder

Proposed solution

Set a fixed version of electron-builder in the https://github.com/ElectronNET/Electron.NET/blob/main/src/ElectronNET.CLI/Commands/BuildCommand.cs#L201 to avoid unexpected behaviour in the future.

Originally created by @Thokerb on GitHub (Jun 5, 2024). <!-- Please search existing issues to avoid creating duplicates. --> <!-- Which version of Electron.NET CLI and API are you using? --> <!-- Please always try to use latest version before report. --> ElectronNET.CLI Version: 23.6.2.0 * **Version**: <!-- Which version of .NET Core and Node.js are you using (if applicable)? --> .Net 6 Node.JS v18.18.2 <!-- What target are you building for? --> * **Target**: electronize build /target win <!-- Enter your issue details below this comment. --> <!-- If you want, you can donate to increase issue priority (https://donorbox.org/electron-net) --> When building the project with target win as portable and then trying to run it, the following error message is appearing. There are no errors during building the application. `cannot find module '@socket.io/component-emitter'` After inspecting the created app.asar archive, the package is included. When running `electronize start`, then the app is starting without problems. Steps to Reproduce: 1. Run `electronize build /target win` 2. Try to start the portable executable 3. Error message `cannot find module '@socket.io/component-emitter'` appears ### Reason: This is related to the issue https://github.com/electron-userland/electron-builder/issues/8244 . I don't know the exact problem of the new electron-builder, but when switching back to version [24.13.3](https://www.npmjs.com/package/electron-builder/v/24.13.3) of the electron-builder the application can start after building. ### Intermediate solution: Set electron-builder version to 24.13.3 locally ```bash npm install -g electron-builder@24.13.3 npm link electron-builder ``` ### Proposed solution Set a fixed version of electron-builder in the https://github.com/ElectronNET/Electron.NET/blob/main/src/ElectronNET.CLI/Commands/BuildCommand.cs#L201 to avoid unexpected behaviour in the future.
claunia added the bug label 2026-01-29 16:52:40 +00:00
Author
Owner

@josep-llodra commented on GitHub (Oct 16, 2024):

I am facing a similar error: cannot find module 'ws' error

Building works, running in development works, but it is when opening using the generated exe.

image

This seems that happened overnight.
Did any package changed and caused this? Any hint will be appreciated


EDIT: found the issue, it is related to signalR client that I am using.

Since Electron.Net uses node integration, and does not isolate context, signalR library thinks it is running in a node environment, and try to require the "ws" library.

I don't have a solution but I did the obvious workaround: modify the code of the signalR library. Hope they give some alternative. https://github.com/dotnet/aspnetcore/issues/49065#issuecomment-2419224022

@josep-llodra commented on GitHub (Oct 16, 2024): I am facing a similar error: `cannot find module 'ws'` error Building works, running in development works, but it is when opening using the generated `exe`. ![image](https://github.com/user-attachments/assets/e8923406-bb67-4200-ac5a-b2a6da387379) This seems that happened overnight. Did any package changed and caused this? Any hint will be appreciated --- EDIT: found the issue, it is related to signalR client that I am using. Since Electron.Net uses node integration, and does not isolate context, signalR library thinks it is running in a node environment, and try to require the "ws" library. I don't have a solution but I did the obvious workaround: modify the code of the signalR library. Hope they give some alternative. https://github.com/dotnet/aspnetcore/issues/49065#issuecomment-2419224022
Author
Owner

@misk0225 commented on GitHub (Apr 21, 2025):

I am facing a similar error: cannot find module 'ws' error

Building works, running in development works, but it is when opening using the generated exe.

I had the same problem and tried exporting the dependencies as extraResources, which worked, but was absolutely stupid and the packaged archive was too large.

@misk0225 commented on GitHub (Apr 21, 2025): > I am facing a similar error: ``cannot find module 'ws'`` error > > Building works, running in development works, but it is when opening using the generated ``exe``. I had the same problem and tried exporting the dependencies as **extraResources**, which worked, but was absolutely stupid and the packaged archive was too large.
Author
Owner

@FlorianRappl commented on GitHub (Oct 31, 2025):

Outdated - use ElectronNET.Core and ElectronNET.Core.AspNet.

See Wiki / What's New.

@FlorianRappl commented on GitHub (Oct 31, 2025): Outdated - use `ElectronNET.Core` and `ElectronNET.Core.AspNet`. See [Wiki / What's New](https://github.com/ElectronNET/Electron.NET/wiki/What's-New).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#953