0

我试图在 Ubuntu 14.04 LTS 上的 nodejs 中运行 MQTT 服务器

var mosca = require('mosca')

var settings = {
port: 1883,
persistence: mosca.persistence.Memory
};

var server = new mosca.Server(settings, function() {
console.log('Mosca server is up and running')
});

server.published = function(packet, client, cb) {
if (packet.topic.indexOf('echo') === 0) {
return cb();
}

var newPacket = {
topic: 'echo/' + packet.topic,
payload: packet.payload,
retain: packet.retain,
qos: packet.qos
};

console.log('newPacket', newPacket);

server.publish(newPacket, cb);
}

它抛出以下错误:

/home/ubuntu/node_modules/mosca/node_modules/qlobber/lib/qlobber.js:227
    for (w of st.keys())
           ^^ SyntaxError: Unexpected identifier
    at Module._compile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/home/ubuntu/node_modules/mosca/node_modules/qlobber/index.js:3:18)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)

谁能帮助我做错了什么?

4

1 回答 1

0

of是较新的 ECMAScript 规范中的关键字,因此 mosca 使用的 qlobber 模块似乎需要比 nodejs 0.10.x 更新的东西

于 2016-09-25T18:29:52.083 回答