Togihun
September 3, 2021, 3:53pm
1
I wanted to create a discord bot but at the running part, the console said:
/home/runner/Szemetes/node_modules/discord.js/src/rest/RESTManager.js:32
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" },
Togihun
September 3, 2021, 4:12pm
4
now it says:
Replit: Updating package configuration
package.json: invalid character ’ " ’ after top-level value
‘Replit: package operation failed’
@SteGriff nullish coalescing is actually supported in js, but it’s a relatively new feature and works differently to the logical or.
@Austin_Westphal can you make sure you’re using node v14 or above? In your package.json, add the following:
"engines": {
"node": "14.x"
}
However it looks like you’re probably using discord.js v13, so you’ll need to use node 16 instead.
Happy Glitching!
Try changing
"engines": { "node": "14.x.x" },
to
"engines": { "node": "16.x.x" },
Yonle
September 5, 2021, 5:37pm
8
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:
Hi there - we typically only support LTS versions of Node, and 16 won’t be LTS until October (Releases | Node.js ), but I’ll see if we can make this work.
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
wh0
September 5, 2021, 6:34pm
9
I heard that they later added it:
Hello again! We just deployed a change that will add Node 16.6 to containers. Due to our 12 hour container cycling schedule, though, it may take up to…12 hours for your projects to be able to use it, so update responsibly!
Nonetheless that your launcher project is nice and more flexible overall.
1 Like
tleylan
September 6, 2021, 8:34pm
10
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.
2 Likes
system
Closed
March 5, 2022, 8:34pm
11
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.