Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zeromq + vite + electron + react === fail (MAIN PROCESS! NOT RENDERER!) #19123

Closed
7 tasks done
devzzzero opened this issue Jan 2, 2025 · 0 comments
Closed
7 tasks done

Comments

@devzzzero
Copy link

devzzzero commented Jan 2, 2025

Describe the bug

Hi. I am trying to get an electron project up and running with zeromq, but having bizarre issues:
Please refer tohttps://github.com/zeromq/zeromq.js/issues/676
and webpack/webpack#18995 (reply in thread)
and zeromq/zeromq.js#690

Reproduction

https://github.com/devzzzero/vite-zeromq-bug

Steps to reproduce

see readme.md in the repo

  • npm install
  • npm run dev to see code fail

System Info

System:
    OS: Linux 5.14 openSUSE Leap 15.5
    CPU: (8) x64 Intel(R) Xeon(R) W-2225 CPU @ 4.10GHz
    Memory: 45.07 GB / 62.49 GB
    Container: Yes
    Shell: 5.6 - /bin/zsh
  Binaries:
    Node: 22.11.0 - /pkgs/volta/tools/image/node/22.11.0/bin/node
    Yarn: 4.5.2 - /pkgs/volta/tools/image/yarn/4.5.2/bin/yarn
    npm: 10.9.0 - /pkgs/volta/tools/image/npm/10.9.0/bin/npm
  Browsers:
    Brave Browser: 131.1.73.104
  npmPackages:
    @vitejs/plugin-react: ^4.2.1 => 4.3.4 
    vite: ^5.1.6 => 5.4.11

Used Package Manager

npm

Logs

D5280:x86_64-Linux5:~/gui/vite-bug/ZMQTest>npm run dev

> [email protected] dev
> vite

Port 5173 is in use, trying another one...
vite v5.4.11 building for development...

watching for file changes...
vite v5.4.11 building for development...

watching for file changes...

  VITE v5.4.11  ready in 509 ms

  ➜  Local:   http://localhost:5174/
  ➜  Network: use --host to expose
  ➜  press h + enter to show help

build started...
build started... (x2)
transforming (1) electron/preload.ts✓ 1 modules transformed.
transforming (1) electron/main.tsrendering chunks (1)...computing gzip size (0)...computing gzip size (1)...dist-electron/preload.mjs  0.67 kB │ gzip: 0.27 kB
built in 52ms.
✓ 21 modules transformed.
rendering chunks (1)...computing gzip size (0)...computing gzip size (1)...dist-electron/main.js  27.30 kB │ gzip: 6.15 kB
built in 219ms.
App threw an error during load
Error: Failed to load zeromq.js addon.node: ReferenceError: __dirname is not defined
ReferenceError: __dirname is not defined
    at findAddon (file:///home/jason/gui/vite-bug/ZMQTest/dist-electron/main.js:45:71)
    at file:///home/jason/gui/vite-bug/ZMQTest/dist-electron/main.js:72:15
    at ModuleJob.run (node:internal/modules/esm/module_job:222:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
    at async loadApplicationPackage (file:///home/jason/gui/vite-bug/ZMQTest/node_modules/electron/dist/resources/default_app.asar/main.js:129:9)
    at async file:///home/jason/gui/vite-bug/ZMQTest/node_modules/electron/dist/resources/default_app.asar/main.js:241:9
    at findAddon (file:///home/jason/gui/vite-bug/ZMQTest/dist-electron/main.js:65:11)
    at file:///home/jason/gui/vite-bug/ZMQTest/dist-electron/main.js:72:15
    at ModuleJob.run (node:internal/modules/esm/module_job:222:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
    at async loadApplicationPackage (file:///home/jason/gui/vite-bug/ZMQTest/node_modules/electron/dist/resources/default_app.asar/main.js:129:9)
    at async file:///home/jason/gui/vite-bug/ZMQTest/node_modules/electron/dist/resources/default_app.asar/main.js:241:9
A JavaScript error occurred in the main process
Uncaught Exception:
Error: Failed to load zeromq.js addon.node: ReferenceError: __dirname is not defined
ReferenceError: __dirname is not defined
    at findAddon (file:///home/jason/gui/vite-bug/ZMQTest/dist-electron/main.js:45:71)
    at file:///home/jason/gui/vite-bug/ZMQTest/dist-electron/main.js:72:15
    at ModuleJob.run (node:internal/modules/esm/module_job:222:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
    at async loadApplicationPackage (file:///home/jason/gui/vite-bug/ZMQTest/node_modules/electron/dist/resources/default_app.asar/main.js:129:9)
    at async file:///home/jason/gui/vite-bug/ZMQTest/node_modules/electron/dist/resources/default_app.asar/main.js:241:9
    at findAddon (file:///home/jason/gui/vite-bug/ZMQTest/dist-electron/main.js:65:11)
    at file:///home/jason/gui/vite-bug/ZMQTest/dist-electron/main.js:72:15
    at ModuleJob.run (node:internal/modules/esm/module_job:222:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
    at async loadApplicationPackage (file:///home/jason/gui/vite-bug/ZMQTest/node_modules/electron/dist/resources/default_app.asar/main.js:129:9)
    at async file:///home/jason/gui/vite-bug/ZMQTest/node_modules/electron/dist/resources/default_app.asar/main.js:241:9

Validations

@vitejs vitejs locked and limited conversation to collaborators Jan 3, 2025
@hi-ogawa hi-ogawa converted this issue into discussion #19128 Jan 3, 2025

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
None yet
Development

No branches or pull requests

1 participant