Reputation: 317
I'm facing an error while hosting my discord bot on repl.it
I get this error,
/home/runner/JU-Bot/node_modules/discord.js/src/rest/RESTManager.js:32
const token = this.client.token ?? this.client.accessToken;
^
SyntaxError: Unexpected token '?'
It works perfectly fine on my local machine.
Upvotes: 2
Views: 14436
Reputation: 589
To use the latest version of the DiscordJS library you will actually need Node v16+.
I tried to run a server application instance on Vercel that used DiscordJS but it uses Node version 14.x runtime. This ended up as an error and you need to use/host your server in an environment that is Node version 16.x+.
Upvotes: 3
Reputation: 97
That ??
is the nullish coalescing operator. Your error means you're running a version of node.js that does not support it. You'll want to upgrade to at least node version 14 to access this feature. Unfortunately, repl.it does not support upgrading to a newer version unless there is already a version for it when creating the repo.
Upvotes: 6