1
I have a project on my machine that uses Node.js. It runs smoothly, but when I went to pass it to my server on C9.io (Linux) it is giving this error:
user:~/workspace/guidebot (master) $ node index.js
/home/ubuntu/workspace/guidebot/index.js:44
const init = async() => {
^
SyntaxError: Unexpected token (
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
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.runMain (module.js:604:10)
at run (bootstrap_node.js:389:7)
at startup (bootstrap_node.js:149:9)
Since in the index file at line 44 this:
const init = async() => { //Linha 44
// Here we load **commands** into memory, as a collection, so they're accessible
// here and everywhere else.
const cmdFiles = await readdir("./commands/");
client.logger.log(`Loading a total of ${cmdFiles.length} commands.`);
cmdFiles.forEach(f => {
if (!f.endsWith(".js")) return;
const response = client.loadCommand(f);
if (response) console.log(response);
});
The version of Node I’m using on the pc is V8.9.4, and the server version is V6.11.2 Is this the problem?? How do I update the server number?
Ah, you’re using async/await, I hadn’t noticed (I excluded my answer).
– bfavaretto
Yes, most likely the problem is the version of Node.
– bfavaretto
You know how I could update him??
– Henrique
It will depend on the operating system, its permissions. I don’t know how to tell step by step. Take a look here (in English).
– bfavaretto
I ended up discovering that if I give a
node -v
He gives me back the V6.11.2, now if I give onenodejs -v
he gives me V8.9.4! But if I try to start withnode index.js
he gives that mistake, and if I try to start with thenodejs index.js
it gives a different error... I don’t know what else to do '-'– Henrique