mosca:SyntaxError:意外的标识符

时间:2016-09-25 17:50:42

标签: node.js mqtt mosca

我试图在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)

任何人都可以帮助我做错了吗?

1 个答案:

答案 0 :(得分:0)

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