Error with Unexpected token?

Asked

Viewed 246 times

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

  • Yes, most likely the problem is the version of Node.

  • You know how I could update him??

  • 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).

  • 1

    I ended up discovering that if I give a node -v He gives me back the V6.11.2, now if I give one nodejs -v he gives me V8.9.4! But if I try to start with node index.js he gives that mistake, and if I try to start with the nodejs index.js it gives a different error... I don’t know what else to do '-'

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.