I have been working on creating a discord bot using discord.js and TypeScript. However, when I attempt to start the bot by running 'ts-node index.ts', I encounter the following error:
Error: Cannot find module 'node:events'
Require stack:
- /home/ether0p12348/RainCrown/node_modules/discord.js/src/client/BaseClient.js
- /home/ether0p12348/RainCrown/node_modules/discord.js/src/index.js
- /home/ether0p12348/RainCrown/index.ts
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
...
In my bot's root directory within index.ts, I have the following code snippet:
const Discord = require('discord.js')
import DiscordJS, {Intents} from 'discord.js'
...
The '.env' file contains only my token information.
When listing the contents of the directory using 'ls', it shows
index.ts node_modules package.json package-lock.json tsconfig.json
If anyone has insights on how to troubleshoot and fix this error, your guidance would be highly appreciated.
PS: The bot is hosted on a Raspberry Pi running Ubuntu OS.