Ask coding questions

← Back to all posts
Unexpected Token '?'
Kostasn2

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

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
Kostasn2
Comments
hotnewtop
OfficialNoynYT

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

Kostasn2

@OfficialNoynYT Thanks it works!!!!

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?

Kostasn2

@SixBeeps Yes it was working for approximately 2 months

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.

Kostasn2

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

JustCoding123

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

Kostasn2

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

amdjedbens

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

Kostasn2

@amdjedbens With env file