'ERROR "MODULE NOT FOUND" on Typescript index.ts activation
i was building this discord bot using discord.js v13 and everytime i run my code (that i completly did not rip off from https://www.youtube.com/watch?v=JMmUW4d3Noc&t=614s)
Here is my code: Package.json
"name": "Ceeby",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"discord.js": "^13.6.0",
"dotenv": "^16.0.0"
}
}
Index.ts
import DiscordJS, { Intents, Message } from 'discord.js'
import dotenv from 'dotenv'
dotenv.config()
const client = new DiscordJS.Client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES,
]
})
client.on("ready", () => {
console.log("Ceeby Is Active")
})
client.on('messageCreate', (Message) =>{
if(Message.content === 'ping'){
Message.reply({
content: 'pong',
})
}
})
client.login(process.env.TOKEN)
.ENV file
TOKEN=<THIS IS MY TOKEN HERE>
i already tried doing it twice, restarting, reinstalling everything and still the same problem. here is the error: `Error: Cannot find module 'node:events' Require stack:
- C:\Users\Fady Mena\Desktop\Ceeby\node_modules\discord.js\src\client\BaseClient.js
- C:\Users\Fady Mena\Desktop\Ceeby\node_modules\discord.js\src\index.js
- C:\Users\Fady Mena\Desktop\Ceeby\index.ts at Function.Module._resolveFilename (internal/modules/cjs/loader.js:962:15) at Function.Module._resolveFilename.sharedData.moduleResolveFilenameHook.installedValue [as _resolveFilename] (C:\Users\Fady Mena\AppData\Roaming\npm\node_modules\ts-node\node_modules@cspotcode\source-map-support\source-map-support.js:679:30) at Function.Module._load (internal/modules/cjs/loader.js:838:27) at Module.require (internal/modules/cjs/loader.js:1022:19) at require (internal/modules/cjs/helpers.js:72:18) at Object. (C:\Users\Fady Mena\Desktop\Ceeby\node_modules\discord.js\src\client\BaseClient.js:3:22) at Module._compile (internal/modules/cjs/loader.js:1118:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1138:10) at Module.load (internal/modules/cjs/loader.js:982:32) at Function.Module._load (internal/modules/cjs/loader.js:875:14) { code: 'MODULE_NOT_FOUND', requireStack: [ 'C:\Users\Fady Mena\Desktop\Ceeby\node_modules\discord.js\src\client\BaseClient.js', 'C:\Users\Fady Mena\Desktop\Ceeby\node_modules\discord.js\src\index.js', 'C:\Users\Fady Mena\Desktop\Ceeby\index.ts' ] } `
Solution 1:[1]
Discord.js V13 requires a node version greater than 16.9.0 and you are running a version older than that as node:events was introduced in node V16+(Unsure which one exactly)
https://github.com/discordjs/discord.js

Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Arnav Mishra |
