Unexpected token discord.js

I wanted to create a discord bot but at the running part, the console said:

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

SyntaxError: Unexpected token ‘?’
can somene help me?
thank you

Add this to your package.json

"engines": { "node": "14.x.x" },

ok i’ll try

now it says:
Replit: Updating package configuration
package.json: invalid character ’ " ’ after top-level value
‘Replit: package operation failed’

Try changing

"engines": { "node": "14.x.x" },


"engines": { "node": "16.x.x" },

same error

I have discord.js 13.1.0

Discord.js requires node version 16.6+ in order to get it working.

Currently, Node v16.6 is not available on glitch as stated at here:

However, There’s a unofficial implementation to get node v16.8+ Working on Glitch.com which can found at here:
Nodejs-Launcher - A simple nodejs launcher that executes a latest nodejs binary

I heard that they later added it:

Nonetheless that your launcher project is nice and more flexible overall.

1 Like

There is no major issue using discord.js v13 so long as (if this is an older bot) you update the code as needed. Much of the syntax has changed from the earlier version. My advice any time anything is acting particularly peculiar is to “step back and start again”. Simply set up an “echo” bot for instance. Nothing to do with REST, nothing to do with replit, etc.

When that is running add the parts you need back in making certain that things continue to run.