0

I have the latest node version installed v16 and when i start the bot with the run button or the console it brings me this error:

const token = this.client.token ?? this.client.accessToken;
                                     ^

SyntaxError: Unexpected token '?' 

But when using shell and typing in node index.js it works fine. So I don't understand what's repl.it so upset about when all is up-to-date?

PackOf20
  • 334
  • 2
  • 17
  • _"when i start the bot with the run button or the console"_... could you elaborate on this please? What exactly are you doing to _"start the bot"_? – Phil Sep 28 '21 at 04:10
  • Click on the green button that says `run` or typing `node index.js` in the console. – PackOf20 Sep 28 '21 at 12:19
  • Does this answer your question? [How to solve error "SyntaxError: Unexpected token '?'"](https://stackoverflow.com/questions/68692038/how-to-solve-error-syntaxerror-unexpected-token) – MrMythical Nov 07 '21 at 16:21

1 Answers1

2

Run npm install node@16 in shell

Create a file called .replit

Inside the .replit file, add run = "npx node index.js". If your main file has a different name change index.js to your main file's name.

Now when you click run, replit uses node.js v16 instead of v12

Dregg
  • 653
  • 6
  • 17
  • This works, but strange. Still don't understand why it's worked with `npm install node@16` when I've tried other methods I've found online too – PackOf20 Sep 28 '21 at 12:23