Skip to content
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

Failed to load zeromq.js addon.node: ReferenceError: __dirname is not defined #675

Closed
yuqianliuli opened this issue Nov 15, 2024 · 2 comments
Labels

Comments

@yuqianliuli
Copy link

Describe the bug Failed to load zeromq.js addon.node: ReferenceError: __dirname is not defined

Reproducing I create a vue project and use typescript. It is a pure project created by the command npm create vue@latest and then I install the zeromq amd use it like this:
code :

<script setup lang="ts">
import TheWelcome from '../components/TheWelcome.vue'
import * as zmq from 'zeromq'
import { onMounted, watch, ref, reactive, onUnmounted } from 'vue'
onMounted(() => {
  async () => {
   let socket = new zmq.Subscriber()
    socket.connect('tcp://127.0.0.1:5556')
    socket.subscribe('datarecv')
    console.log('Subscriber connected to port 5556')
    for await (const [topic, msg] of socket) {
      console.log('received a message related to:', topic, 'containing message:', msg)
    }
  }
})

when I open the browser ,this comes out:
Failed to load zeromq.js addon.node: ReferenceError: __dirname is not defined
image

Tested on

  • OS: [Windows 10]
@aminya
Copy link
Member

aminya commented Nov 15, 2024

You can't run zeromq inside the browser. It is designed to be used with Nodejs.

@aminya aminya closed this as completed Nov 15, 2024
@yuqianliuli
Copy link
Author

Thank you .BTW ,Can you tell me how can I use the zeromq in a electron-vue project ? I've been troubled for several days

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants