Module not found: Can't resolve 'worker_threads'

./node_modules/@discordjs/ws/dist/index.js:113:0
Module not found: Can't resolve 'worker_threads'

https://nextjs.org/docs/messages/module-not-found

Import trace for requested module:
./node_modules/discord.js/src/index.js
./src/Bot/BotWorker.mjs
./src/utils/check.js
./src/pages/dashboard/[id]/leveling.tsx
./node_modules/@discordjs/ws/dist/index.js:113:0
Module not found: Can't resolve 'worker_threads'

https://nextjs.org/docs/messages/module-not-found

Import trace for requested module:
./node_modules/discord.js/src/index.js
./src/Bot/BotWorker.mjs
./src/utils/check.js
./src/pages/dashboard/[id]/leveling.tsx
currently developing a dashboard using nextjs but it seems to not start because discord.js requires some module that i cant find
3 Replies
d.js toolkit
d.js toolkit16mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
kobeeeef
kobeeeefOP16mo ago
node v18.17.1 why is that? im starting the file using 2 different scripts?
"dev": "concurrently \"node -r dotenv/config src/Bot/BotWorker.mjs\" \"next dev\"",

"dev": "concurrently \"node -r dotenv/config src/Bot/BotWorker.mjs\" \"next dev\"",

oh i see. dang so the only way would be through a external API? yeah i ended up just sending a request directly to the discord api as i only need guilds list etc
Yuvraj Rathva
Yuvraj Rathva8mo ago
I am encountering same error while importing Client from discord.js in index.tsx I am using node ^20.4.5 and discord.js ^14.14.1 version. Here is my code of index.tsx
// some other imports

import { Client } from "discord.js";

const client = new Client({
intents: ["Guilds", "GuildMessages", "DirectMessages"],
});
client.once("ready", () => {
console.log("Discord bot is ready! 🤖");
});

// some other code
// some other imports

import { Client } from "discord.js";

const client = new Client({
intents: ["Guilds", "GuildMessages", "DirectMessages"],
});
client.once("ready", () => {
console.log("Discord bot is ready! 🤖");
});

// some other code
I am not able to understand above discussion about how @Shawty solve this problem, please help me out how can I fix this Understood, So the best way to run bot is using concurrently in "dev" as Shawty did. Thank you for the help.
Want results from more Discord servers?
Add your server