I am currently working on a Discord.js Bot in replit. The example code I found, which I used to get started with the bot, begins with this line of code.const { Client, Intents, Message } = require('discord.js'); const client = new Client( { intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] } );
I am trying to style the console/terminal output with chalk. However, Chalk requires ESM. To fix this, I go into package.json and add "type":"module"
. At this point, the chalk works, but not discord.js, because it uses require()
. How would I change the require into an import
line?
Asked
Active
Viewed 266 times
0

bmp
- 31
- 1
- 7
1 Answers
0
you can try using package named bable, as it will compile your code down into supported one. you can read about it here https://github.com/babel/babel

Eric Pradana
- 16
-
I honestly don't know how, but I somehow did this post twice, https://stackoverflow.com/questions/72205284/chalk-issues-in-nodejs/72205737#72205737 – bmp May 11 '22 at 23:23