Kuldeep Kumar Kuldeep Kumar - 2 months ago 71
Node.js Question

mosca: SyntaxError: Unexpected identifier

I was trying to run a MQTT server in nodejs on Ubuntu 14.04 LTS

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);
}


it is throwing following error:

/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)


Can anyone help what is that I am doing wrong?

Answer

of is a keyword in the newer ECMAScript spec, so it appears that the qlobber module used by mosca requires something newer than nodejs 0.10.x

Comments