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

Cannot resolve module 'net' #119

Open ryoia opened 9 years ago

ryoia commented 9 years ago

I installed this and got the Cannot resolve module 'net' error, is this not okay to use in browser?

The error is from node_modules/stompjs/lib/stomp-node.js

rfox90 commented 9 years ago

https://github.com/jmesnil/stomp-websocket/blob/master/lib/stomp.js

Is the browser file. The node one will only work in a NodeJS Environment. It calls require using some Node modules.

ChrisCooney commented 7 years ago

Hi guys, From NPM, how do you go about just including the client friendly version? I am struggling to use this in a react application.

supergicko commented 7 years ago

i have the same issue like @ChrisCooney, would be really nice to have it in a npm package

jonahe commented 7 years ago

@ChrisCooney @supergicko

I almost got it to work as expected when I "required" Stomp like this var Stomp = require("stompjs/lib/stomp.js").Stomp That gets you the browser version which doesn't have the 'net' dependency, but I had other problems so I can't confirm that it works fully.

(This is after I installed it through npm as usual, with npm install stompjs --save)

flyleft commented 7 years ago

I have the same issue,but i solved it by "npm i net -S"

mattdell commented 7 years ago

For me this is an issue with Webpack. If you are using Webpack the ideal fix is to add this to your webpack config:

node: {
  net: 'empty',
},

Similar issue here: https://github.com/hapijs/joi/issues/665#issuecomment-113713020

skrajath commented 7 years ago

you can do this in webpackconfig

var node_dir = __dirname + '/node_modules';

resolve: {
        alias: {
            'stompjs': node_dir + '/stompjs/lib/stomp.js',
        }
    }
JosephSKh commented 6 years ago

@jcalaz solved my issue @flyleft

darwayne commented 6 years ago

for anyone else having this issue, another solution is using a cdn for this instead of bundling it with your application.

RahulKwani commented 6 years ago

Thanks @flyleft for solution.

Wouldn't making net as peer dependencies solve this issue?

sonee123 commented 5 years ago

Thanks @flyleft it's working for me.

thukuwanjiku commented 5 years ago

@flyleft your solution helped me much in a very different use case. Biggup!

peterpwang commented 5 years ago

Thanks @flyleft it's working for me too.

muhammad-Usman85 commented 4 years ago

npm i net -S

also work

vivek-frontenddeveloper commented 4 years ago

@flyleft you are really awesome

PiyushDangre commented 4 years ago

I have the same issue,but i solved it by "npm i net -S"

Thank you so very much @flyleft . You are awesome :)

YashithChanuka commented 4 years ago

I have the same issue,but i solved it by "npm i net -S"

This works for me. Thanks.

mcasters commented 4 years ago

Have you seen what this package is ? It seems very strange... https://github.com/sleeplessinc/net/blob/master/index.js I really don't understand what it is for ?!

eranf91 commented 3 years ago

It has been 5 years and problem still occurs. why shoul I install the net depdency? what does it do?

Polve commented 3 years ago

This package is unmantanained, there are other packages if you need to use stomp over websockets, for example https://github.com/stomp-js/stompjs or https://github.com/JSteunou/webstomp-client

varHarrie commented 1 year ago

Note: After webpack 5, you should use resolve.fallback, for example:

{
  resolve: {
    fallback: {
      net: false,
    },
  },
}
pritamTech212 commented 7 months ago

Thanks @flyleft it's working for me too. And still working in 2024