'node:events' Error in my Discord bot

Hello Friends, I Can’t Solve Error: Cannot find module ‘node:events’ on my Discord bot. Can you help?
Note: The enable-pnpm command did not fix the problem

Console Error;

    throw err;
Error: Cannot find module 'node:events'
Require stack:
- /rbd/pnpm-volume/8a19f291-9eab-4f97-84a3-019a804353eb/node_modules/discord.js/src/client/BaseClient.js
- /rbd/pnpm-volume/8a19f291-9eab-4f97-84a3-019a804353eb/node_modules/discord.js/src/index.js
- /app/bot.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:610:15)
    at Function.Module._load (internal/modules/cjs/loader.js:526:27)
    at Module.require (internal/modules/cjs/loader.js:666:19)
    at require (internal/modules/cjs/helpers.js:16:16)
    at Object.<anonymous> (/rbd/pnpm-volume/8a19f291-9eab-4f97-84a3-019a804353eb/node_modules/discord.js/src/client/BaseClient.js:3:22)
    at Module._compile (internal/modules/cjs/loader.js:759:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:770:10)
    at Module.load (internal/modules/cjs/loader.js:628:32)
    at Function.Module._load (internal/modules/cjs/loader.js:555:12)
    at Module.require (internal/modules/cjs/loader.js:666:19)```

Hi there - can you confirm that you’re using the required version of Node for discord.js, Node 16.6? I believe you are not, which is why it cannot find that native module.

I Did What You Said But Now I’m Getting This Error

    throw new RangeError('BITFIELD_INVALID', bit);
RangeError [BITFIELD_INVALID]: Invalid bitfield flag or number: everyone.
    at Function.resolve (/rbd/pnpm-volume/8a19f291-9eab-4f97-84a3-019a804353eb/node_modules/discord.js/src/util/BitField.js:152:11)
    at /rbd/pnpm-volume/8a19f291-9eab-4f97-84a3-019a804353eb/node_modules/discord.js/src/util/BitField.js:147:54
    at Array.map (<anonymous>)
    at Function.resolve (/rbd/pnpm-volume/8a19f291-9eab-4f97-84a3-019a804353eb/node_modules/discord.js/src/util/BitField.js:147:40)
    at Client._validateOptions (/rbd/pnpm-volume/8a19f291-9eab-4f97-84a3-019a804353eb/node_modules/discord.js/src/client/Client.js:546:33)
    at new Client (/rbd/pnpm-volume/8a19f291-9eab-4f97-84a3-019a804353eb/node_modules/discord.js/src/client/Client.js:73:10)
at Object.<anonymous> (/app/bot.js:3:16)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32) {
  [Symbol(code)]: 'BITFIELD_INVALID'

I’m going to guess that you have a RangeError due to an invalid bitfield.

You can search Google or Bing for these errors and find out what causes them. We can’t see your code which makes it slightly harder for the folks here.

Since I wrote the articles from google translate, I could understand a little, but I think you asked for the error code;

const client = new Discord.Client({ intents: ["everyone"] });

Note: I searched on Google but couldn’t find any results related to my mistake or (I’m new to this stuff)
I do not understand

Display of the error in the console;

Error Code;
Line 3

do you think it could be “MENTION_EVERYONE”?

I changed my code to “MENTION_EVERYONE” as you said but I keep getting the same error

Is there a possibility that there are errors elsewhere in the code?

I didn’t actually say it was MENTION_EVERYONE. I was pointing out that “everyone” was probably not a legitimate intent because it was not listed.

You should do one of two things in my opinion. If you understand programming then read the Discord.js docs. If you are relatively new to it then follow an example that already works until you understand the basics.

You need to understand what a string is, what a number is, etc. It isn’t fun but it is necessary. Is the array of intents supposed to be string values? The docs say “bitfield” so it isn’t likely to be string right?

intents are not the same as permissions, below are the allowed intents, which can be inputted into an array


A nice solution is settings the Intents to the following
intents: Object.keys(Discord.Intents.FLAGS).map(x => Discord.Intents.FLAGS[x])

1 Like

It is considered a very bad idea to request intents a bot does not need. The use of something like GUILD_MESSAGE_TYPING to name one means an event will be called on your bot as messages are typed despite the average bot having no interest in it at all.

So You Are Now Saying, That Command is unnecessary in the bot Then I will delete that command.

I think the command was necessary I got errors in many places

Can I add another command instead of everyone?, Or it seems like I can’t get out of this.

Now I Added ‘GUILD MESSAGES’ Command and I am getting this error.

Command On bot.js;

Line 3


I Changed the Command;


But I still get an error, but my bot seems active, its okay?


Since most of my commands, almost all of them start with a client, naturally I try to define the client for my bot, but I can’t.

Example Command For Client;


Writing a Discord bot typically won’t work if you just guess at the syntax. Have you read the documentation, watched a introductory video or followed an online example? You don’t conclude “lots of things start with client. so I’ll start mine that way”.

The real problem you are having and I mean this sincerely is that you aren’t thinking or studying anything before you start typing.

if (msg.content.toLowerCase() === 'Hi") will never, ever be true so you will never, ever see Hi Bro Welcome. These are introductory JavaScript issues and nothing to do with Discord.

So I’ll never be able to make a discord bot okay
no use keeping you busy, have a nice day sir

You will easily be able to make a discord bot if you start with simple examples that work. You get an example working and you edit that. When it breaks you discover what you did that made it break and repair it. As you get better you add new features.

If something doesn’t make sense you ask people for help. I’ve explained that the toLowerCase example cannot return true. If you were really interested you might discover why and be closer to writing that bot.

Never too busy to help but much too busy to write your entire app. :slight_smile:

The bot I made comes from a ready-made infrastructure and I watched a tutorial video, the guy showed a simple bot construction, I added something to the commands, delete chat command, etc. I got the error and when I opened the internet, I couldn’t find the source of the problem and asked for help here. Additionally google translate may have translated it wrong but I was always seeing the Hi Bro Welcome message, I’m just trying to make a “Simple” bot to have fun with my friends