eventsource icon indicating copy to clipboard operation
eventsource copied to clipboard

util.inherits is not a function

Open enverbisevac opened this issue 2 years ago • 5 comments

I tried to integrate this lib into my project using ViteJS but error is displayed: Uncaught TypeError: util.inherits is not a function at node_modules/eventsource/lib/eventsource.js

enverbisevac avatar Feb 17 '22 00:02 enverbisevac

My workaround is to use the EventSourcePolyfill

cosnt es = new window['EventSourcePolyfill']('http://example.com')

Hope this help someone while wait for a fix

hong-duc avatar Apr 15 '22 08:04 hong-duc

@hong-duc how do you populate window with EventSourcePolyfill?

Addeuz avatar May 12 '22 11:05 Addeuz

In general I would recommend you use a browser-oriented polyfill if that is what you need - eg https://github.com/amvtek/EventSource

rexxars avatar May 16 '22 12:05 rexxars

I don't have a need for it really. I was just curious on how to do it since I would like to use this polyfill.. But because of the bug I've had to resort to using this: https://github.com/Yaffle/EventSource even if it did some political changes..

Addeuz avatar May 17 '22 06:05 Addeuz

face the same problem too

hd10180 avatar Mar 03 '23 06:03 hd10180