I am currently using node v16.14.0 as per the title and getting this error:
Error: Cannot find module 'node:events'
Require stack:
- /Users/username/bp/bp-website/backend/node_modules/discord.js/src/client/BaseClient.js
- /Users/username/bp/bp-website/backend/node_modules/discord.js/src/index.js
- /Users/username/bp/bp-website/backend/discord/bot.js
- /Users/username/bp/bp-website/backend/discord/purchase.js
- /Users/username/bp/bp-website/backend/webserver.js
- /Users/username/bp/bp-website/backend/index.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:924:15)
at Function.Module._load (node:internal/modules/cjs/loader:769:27)
at Module.require (node:internal/modules/cjs/loader:996:19)
at require (node:internal/modules/cjs/helpers:92:18)
at Object.<anonymous> (/Users/username/bp/bp-website/backend/node_modules/discord.js/src/client/BaseClient.js:3:22)
at Module._compile (node:internal/modules/cjs/loader:1092:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
at Module.load (node:internal/modules/cjs/loader:972:32)
at Function.Module._load (node:internal/modules/cjs/loader:813:14)
at Module.require (node:internal/modules/cjs/loader:996:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/Users/username/bp/bp-website/backend/node_modules/discord.js/src/client/BaseClient.js',
'/Users/username/bp/bp-website/backend/node_modules/discord.js/src/index.js',
'/Users/username/bp/bp-website/backend/discord/bot.js',
'/Users/username/bp/bp-website/backend/discord/purchase.js',
'/Users/username/bp/bp-website/backend/webserver.js',
'/Users/username/bp/bp-website/backend/index.js'
]
}
I have looked at other questions, however, they all say upgrade to Node v16.6 which I downgraded to to test but also still didn't work. Any help would be greatly appreciated!
CodePudding user response:
Run node -v in the terminal. If the output is v16.6.0 or higher, you're good to go, because the required version of discord.js is v16.6.0 or higher. Click here to read full documentation from discord.js . Without the latest version of node.js you might get errors like:
1.Unexpected token '?'
2.Cannot find module: 'node:events'
CodePudding user response:
const client = new Discord.Client({ intents: ["DIRECT_MESSAGES", "GUILD_MESSAGES"] });
instead of:
const client = new Discord.Client();