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

Error: Class extends value undefined is not a constructor or null #27

Closed
antonlovric opened this issue Jul 27, 2023 · 4 comments
Closed

Comments

@antonlovric
Copy link

antonlovric commented Jul 27, 2023

Hey everyone, I have a RabbitMQ broker running in the background and a .NET Core backend publishing messages. I need to connect to the broker inside my React app I created using Vite. This is the code I use for connecting to the broker:

import { Connection } from 'rabbitmq-client';

  useEffect(() => {
    const rabbit = new Connection("amqp://guest:guest@localhost:5672");

    rabbit.on('connection', () => {
      console.log('connected');
    });
    rabbit.on('error', () => {
      console.log('error');
    });

    return () => {
      rabbit.close();
    };
  }, []);

But I get this error when the code snippet is called:

Uncaught TypeError: Class extends value undefined is not a constructor or null
    at node_modules/rabbitmq-client/lib/util.js (util.js:106:43)
    at __require2 (chunk-WQG2LZMB.js?v=fa4e550a:16:50)
    at node_modules/rabbitmq-client/lib/Connection.js (Connection.js:11:16)
    at __require2 (chunk-WQG2LZMB.js?v=fa4e550a:16:50)
    at node_modules/rabbitmq-client/lib/index.js (index.js:4:22)
    at __require2 (chunk-WQG2LZMB.js?v=fa4e550a:16:50)
    at index.js:12:126

Any idea what I'm doing wrong or what I can do to resolve this issue?

Side note, this warning also shows up in the browser console:

Module "node:stream" has been externalized for browser compatibility. Cannot access "node:stream.Writable" in client code. See http://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
@cody-greene
Copy link
Owner

cody-greene commented Jul 27, 2023 via email

@antonlovric
Copy link
Author

antonlovric commented Jul 27, 2023

Oh alright, do you have any recommendations which library I can use on the client side?

@cody-greene
Copy link
Owner

cody-greene commented Jul 27, 2023 via email

@antonlovric
Copy link
Author

Thanks!

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

No branches or pull requests

2 participants