ng2-mqtt
ng2-mqtt copied to clipboard
ReferenceError: window is not defined
Hello, I am using Angular 4 CLI + Universal and I am getting always following error:
/Users/Picchu/Documents/em/node_modules/ng2-mqtt/mqttws31.js:2143
})(window);
ReferenceError: window is not defined
at Object.<anonymous> (/Users/Picchu/Documents/em/node_modules/ng2-mqtt/mqttws31.js:2143:4)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at Object.defineProperty.value (/Users/Picchu/Documents/em/dist/server.js:6948:18)
at __webpack_require__ (/Users/Picchu/Documents/em/dist/server.js:20:30)
How can I fix this?
I don't think that the js lib that is used in this project (mqttws31) is supported in cli mode. The lib would need to be rewritten to take this into account, since its currently using setTimeout to schedule the pinger.
Ok and how I should do this? Within your lib or in my Angular component? The problem occurs on server side. I am using Node.js with Angular CLI + Universal
This is part of the Paho mqttws31 lib and its there that the change needs to happen.