Open ryoia opened 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.
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.
i have the same issue like @ChrisCooney, would be really nice to have it in a npm package
@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
)
I have the same issue,but i solved it by "npm i net -S"
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
you can do this in webpackconfig
var node_dir = __dirname + '/node_modules';
resolve: {
alias: {
'stompjs': node_dir + '/stompjs/lib/stomp.js',
}
}
@jcalaz solved my issue @flyleft
for anyone else having this issue, another solution is using a cdn for this instead of bundling it with your application.
Thanks @flyleft for solution.
Wouldn't making net
as peer dependencies solve this issue?
Thanks @flyleft it's working for me.
@flyleft your solution helped me much in a very different use case. Biggup!
Thanks @flyleft it's working for me too.
npm i net -S
also work
@flyleft you are really awesome
I have the same issue,but i solved it by "npm i net -S"
Thank you so very much @flyleft . You are awesome :)
I have the same issue,but i solved it by "npm i net -S"
This works for me. Thanks.
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 ?!
It has been 5 years and problem still occurs. why shoul I install the net depdency? what does it do?
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
Note: After webpack 5, you should use resolve.fallback, for example:
{
resolve: {
fallback: {
net: false,
},
},
}
Thanks @flyleft it's working for me too. And still working in 2024
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