Skip to content

zeromq + vite + electron also fails (MAIN PROCESS! NOT RENDERER) #690

Open
@devzzzero

Description

@devzzzero

Describe the bug A clear and concise description of what the bug is.

This is similar to #676
I've given up trying to get zeromq working on the renderer side and instead using ipc to hack up the required communication hooks to the renderer from the main process, and managed to get the app limping along and running (on webpack).
However, I ran into what seems to be another blocker. When I package up the app, the resulting app dies because it's unable to find zeromq. Please see webpack/webpack#18995 (reply in thread)

I then tried to get electron+vite+react + zeromq to work, and ran into a strangely similar issue.

Reproducing If possible, provide a list of commands or a code sample that
reproduces the bug that you are observing. Otherwise please describe as much as
possible in which circumstances the bug can be observed.

I followed the instructions on https://electron-vite.github.io/guide/getting-started.html
to get a electron+vite+react.

I then added zeromq and verified that the tests do run using tsx
But ran into this one:

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/electron-vite/Test.GUI/dist-electron/main.js:54:71)
    at file:///home/jason/gui/electron-vite/Test.GUI/dist-electron/main.js:81: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/electron-vite/Test.GUI/node_modules/electron/dist/resources/default_app.asar/main.js:129:9)
    at async file:///home/jason/gui/electron-vite/Test.GUI/node_modules/electron/dist/resources/default_app.asar/main.js:241:9
    at findAddon (file:///home/jason/gui/electron-vite/Test.GUI/dist-electron/main.js:74:11)
    at file:///home/jason/gui/electron-vite/Test.GUI/dist-electron/main.js:81: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/electron-vite/Test.GUI/node_modules/electron/dist/resources/default_app.asar/main.js:129:9)
    at async file:///home/jason/gui/electron-vite/Test.GUI/node_modules/electron/dist/resources/default_app.asar/main.js:241:9

Over on the webpack side, I managed to get past this issue (at least for the "run") by having zeromq listed as an external dependency.
but the packaged app fails.

On vite (this issue), I'm unable to get the app to run at all

Expected behavior A clear and concise description of what you expected to
happen.

I expe
Tested on

  • OS: [e.g. Ubuntu 18.04, Windows 10]
  • opensuse 15.5
  • ZeroMQ.js version: [e.g. 5.1.0, 6.0.0-beta.2]
  • 6.2.0
    TEST-package.json

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions