Skip to content Skip to sidebar Skip to footer

Creating My First Bot Using Replit But Always Error Discord.js

I have just started Discord.JS on Replit. It followed FreeCodeCamp's Tutorial on https://www.freecodecamp.org/news/create-a-discord-bot-with-javascript-nodejs/ But when I runned th

Solution 1:

Discord.js v13 requires Node.js v16.6. Replit only directly supports Node.js v12.16.1 (at the time of writing).

When using an older version of Node.js, you may see errors such as

However, you can install a newer Node.js binary using the node npm package.

Here's a minimal setup:

package.json

{"name":"node.js-v16-on-replit-demo","version":"0.0.1","dependencies":{"discord.js":"^13.2.0","node":"^16.10.0"}}

.replit

run = "npx node ."

index.js

constDiscord = require("discord.js")

// your code...

You can try this out with this demo repl.

If you like, you can define a start npm script:

package.json

{// ..."scripts":{"start":"node ."}}

.replit

run = 'npm start'

There are also plenty of resources online about Node.js v16 on Replit.

Post a Comment for "Creating My First Bot Using Replit But Always Error Discord.js"