jmesnil / stomp-websocket

Stomp client for Web browsers and node.js apps
http://jmesnil.net/stomp-websocket/doc/
Apache License 2.0
1.43k stars 586 forks source link

net module not found in stompjs #164

Open Bugslogger opened 2 years ago

Bugslogger commented 2 years ago

ERROR in ./node_modules/stompjs/lib/stomp-node.js 11:8-22

this error comes from node modules inside stomp. how to fix this if anyone knows, please leave comment below. as soon as it's urgent for me.

Thank you!

Bappy1988 commented 2 months ago

I realise this is a really old issue, but if anyone else comes here looking for it like I did, this is likely because you're using stompjs from NPM in a browser based client app and the default import from the stompjs npm package is the node client that has a TCP fallback built in, which is not available in browsers.

Long story short, you can (possibly) work around it one of 3? ways. 1) import the browser-only version of the file from lib like so; import { Stomp } from "stompjs/lib/stomp.js";

2) include the 'net' npm package npm i net -S

3) get webpack to mock the package for you node: { net: 'empty', },

for a more detailed explanation, see stack overflow comments; https://stackoverflow.com/questions/54275069/module-not-found-error-cant-resolve-net-in-node-modules-stompjs-lib