使用ttn的mqtt-TypeError:“继承”的超级构造函数必须具有原型

时间:2018-07-17 05:14:46

标签: node.js mqtt

我的代码:

var ttn = require("ttn")  
var appID = "***"  
var accessKey = "ttn-account-********************"  
ttn.data(appID, accessKey).then(function (client) {  
    client.on("uplink", function (devID, payload) {  
        console.log("Received uplink from >>>", devID)  
        console.log("payload >>> ", payload);  
    })  
}).catch(function (error) {  
    console.error("Error >>>", error)   
    process.exit(1)  
})  

运行此文件时,出现以下错误:

TypeError: The super constructor to "inherits" must have a prototype
at Object.exports.inherits (util.js:961:11)
at Object.<anonymous> (/home/ben/node_modules/mqtt/node_modules/bl/bl.js:37:6)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/home/ben/node_modules/mqtt/node_modules/mqtt-packet/parser.js:3:10)

同一代码以前在Windows中工作。我刚刚尝试在ubuntu 18.04中运行此代码。现在,我收到此错误。我不确定该错误的来源。因此,我尝试重新安装npm软件包。它不起作用。 请帮助我解决此问题。预先感谢。

0 个答案:

没有答案