I'm working on a React project and tried to install @Stomp/stompjs package which uses the window object under the hood. At the first place, that I run the project the below error occurs:
ReferenceError: window is not defined
at Object.<anonymous> (/Users/.../node_modules/@stomp/stompjs/bundles/webpack:/StompJs/webpack/universalModuleDefinition:10:2)
at Module._compile (internal/modules/cjs/loader.js:774:30)
to solve this problem head over to many solutions across the web, but could not fix the bug.. here's some of my solution that didn't work:
I set 'globalobject' in the output sections of the webpack to different values ..this, window, global, etc.
lazy import of the package