[英]AngularJS “ReferenceError: window is not defined” in NodeJS Application
[英]ReferenceError: window is not defined in nodejs
var pahoMqtt = require("paho-mqtt");
let client = new Paho.MQTT.Client("serverIp", port, "/ws", "clientId" + Math.round((new Date()).getTime() / 1000));
當我在節點服務器上運行此命令時,出現以下錯誤
stack:
[ 'ReferenceError: window is not defined',
' at LibraryFactory (/var/www/html/btrade/server2/node_modules/paho-mqtt/paho-mqtt.js:2411:4)',
' at ExportLibrary (/var/www/html/btrade/server2/node_modules/paho-mqtt/paho-mqtt.js:86:20)',
' at Object.<anonymous> (/var/www/html/btrade/server2/node_modules/paho-mqtt/paho-mqtt.js:97:3)',
' at Module._compile (module.js:652:30)',
' at Module._extensions..js (module.js:663:10)',
' at Object.require.extensions.(anonymous function) [as .js] (/var/www/html/btrade/server2/node_modules/babel-register/lib/node.js:152:7)',
' at Module.load (module.js:565:32)',
' at tryModuleLoad (module.js:505:12)',
' at Function.Module._load (module.js:497:3)',
' at Module.require (module.js:596:17)',
' at require (internal/module.js:11:18)',
' at Object.<anonymous> (/var/www/html/btrade/server2/server/controllers/trade.controller.js:25:16)',
' at Module._compile (module.js:652:30)',
' at loader (/var/www/html/btrade/server2/node_modules/babel-register/lib/node.js:144:5)',
' at Object.require.extensions.(anonymous function) [as .js] (/var/www/html/btrade/server2/node_modules/babel-register/lib/node.js:154:7)',
任何人都可以幫助我如何在節點js中使用Paho.MQTT。 提前謝謝。
Paho Javascript客戶端當前僅在瀏覽器中受支持。
目前正在進行更新工作,因此它可以在NodeJS中運行,但目前尚未完成。
現在,您可以使用MQTT.js庫。 該庫可以在NodeJS和瀏覽器中使用,並支持Websockets上的本機MQTT和MQTT(當在Websockets上的MQTT上的瀏覽器中使用時,可以使用)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.