Reputation: 1653
I have created a new angular app and wanted to use it with mqtt broker. I am following this tutorial - http://www.davidfindlay.com.au/monitoring-mqtt-services-in-an-angular-web-application/.
I have installed ng2-mqtt through angular cli.
I have imported
import {Paho} from 'ng2-mqtt/mqttws31';
in my component.ts
when i do ng serve it compiles sucessfully, but browser throws an error
mqttws31.js:84 Uncaught ReferenceError: Paho is not defined
at Object../node_modules/ng2-mqtt/mqttws31.js (mqttws31.js:84)
at __webpack_require__ (bootstrap:79)
at Module../src/app/ahu/ahu.component.ts (main.js:104)
at __webpack_require__ (bootstrap:79)
at Module../src/app/app.module.ts (app.component.ts:8)
at __webpack_require__ (bootstrap:79)
at Module../src/main.ts (main.ts:1)
at __webpack_require__ (bootstrap:79)
at Object.0 (main.ts:12)
at __webpack_require__ (bootstrap:79)
Any idea what is causing the error.
Upvotes: 0
Views: 1197
Reputation: 31
Had a similar problem. Solved it by following the instruction in https://github.com/awslabs/aws-mobile-appsync-sdk-js/issues/76
simply navigate to ng2-mqtt in node_modules and replace
if (typeof Paho === "undefined") {
Paho = {};
}
with
const Paho = {};
in mqttws31.js
Upvotes: 3