Skip to content
← Back to Community
Unexpected Token '?'
Profile icon
Kostasn2

Iam bulding a discord bot with discord.js and nodejs and my code was running perfectly until i recieved this error,

image

I deleted my repl and re-uploaded, also i tried to re-install discordjs and all packages again, but the error is still there. Also i changed the token and updated in my repl it code and still nothing. Just a reminder, my code runs perfectly on my pc!!

Voters
Profile icon
djejdjfjdkdjcj
Profile icon
Kostasn2
Comments
hotnewtop
Profile icon
OfficialNoynYT

Go into your package.json and try changing discord.js version to ^12.5.3

Profile icon
Kostasn2

@OfficialNoynYT Thanks it works!!!!

Profile icon
SixBeeps

The nullish-coalescing operator was added in Node.js version 14, but Node Repls run on version 12. You said this was working at some point?

Profile icon
Kostasn2

@SixBeeps Yes it was working for approximately 2 months

Profile icon
JustCoding123

For discord.js v13 you need node js 16.6 or higher but the current node version on replit is lower than that so you can't use discord.js v13 in a normal node repl. If you want to use discord.js v13 you have to fork this repl and then move your code into it.

Profile icon
Kostasn2

@JustCoding123 I see, ok that makes sence. But my repl was working.

Profile icon
JustCoding123

@Kostasn2 You problaly had discord.js v12 installed before.

Profile icon
Kostasn2

@JustCoding123 yes yes i changed discord js version and it works again

Profile icon
amdjedbens

how are you importing the token? .env file or plain text ?

Profile icon
Kostasn2

@amdjedbens With env file