简体   繁体   English

运行discord bot时找不到模块'node:events'错误

[英]Cannot find module 'node:events' error thrown when running discord bot

Here is my basic source code, I'm just trying to get the bot online:这是我的基本源代码,我只是想让机器人在线:

const Discord = require('discord.js');
const client = new Discord.Client();

client.once('ready', ()=> {
    console.log('Bot is online')
});

client.login('token');

When I run the program it throws an error:当我运行程序时,它抛出一个错误:

internal/modules/cjs/loader.js:883
  throw err;
  ^

Error: Cannot find module 'node:events'
Require stack:
- D:\Eclipse\Workspace\discordbot\src\node_modules\discord.js\src\client\BaseClient.js
- D:\Eclipse\Workspace\discordbot\src\node_modules\discord.js\src\index.js
- D:\Eclipse\Workspace\discordbot\src\main.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> 
(D:\Eclipse\Workspace\discordbot\src\node_modules\discord.js\src\client\BaseClient.js:3:22)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [

'D:\\Eclipse\\Workspace\\discordbot\\src\\node_modules\\discord.js\\src\\client\\BaseClient.js', 'D:\\Eclipse\\Workspace\\discordbot\\src\\node_modules\\discord.js\\src\\index.js', 'D:\\Eclipse\\Workspace\\discordbot\\src\\main.js' ] } 'D:\\Eclipse\\Workspace\\discordbot\\src\\node_modules\\discord.js\\src\\client\\BaseClient.js', 'D:\\Eclipse\\Workspace\\discordbot\\src\\node_modules\\discord.js\\src\\index.js ', 'D:\\Eclipse\\Workspace\\discordbot\\src\\main.js'] }

I'm currently have node 17.0.0, and using Eclipse.我目前有节点 17.0.0,并使用 Eclipse。 Node is in my path environment.节点在我的路径环境中。 My package JSON file is:我的包 JSON 文件是:

{
  "name": "discordbot",
  "version": "1.0.0",
  "description": "",
  "main": "main.js",
  "scripts": {
   "test": "echo \"Error: no test specified\" && exit 1"
 },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "discord.js": "^13.2.0",
    "node": "^17.0.0"
 }
}

I have looked at similar issues and none of the answers seemed to have fixed the issue.我看过类似的问题,但似乎没有一个答案能解决这个问题。 Discord says that v 16.10.0 or higher will work. Discord 表示 v 16.10.0 或更高版本可以使用。 Thanks for your time.谢谢你的时间。

In order to upgrade node you need to install it globally, not just within the current package.为了升级节点,您需要全局安装它,而不仅仅是在当前包中。 Typically this is done by downloading the installer , or by using your preferred package manager .通常这是通过下载安装程序或使用您喜欢的包管理器来完成的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 discord.js 中的机器人运行错误(错误:找不到模块/代码:'MODULE_NOT_FOUND',requireStack:[]) - Bot running error in discord.js (Error: Cannot find module / code: 'MODULE_NOT_FOUND', requireStack: []) Discord JS - 错误:在节点 v16.14.0 上找不到模块“节点:事件” - Discord JS - Error: Cannot find module 'node:events' on node v16.14.0 Discord.js:错误:更新到 v13 后“找不到模块‘node:events’” - Discord.js: Error: "Cannot find module 'node:events'" after updating to v13 使用 discord.js-musicbot-addon 运行 discord bot 时出错:找不到模块 'm3u8stream/lib/parse-time' - Error running discord bot with discord.js-musicbot-addon: Cannot find module 'm3u8stream/lib/parse-time' |Discord Bot 错误:找不到模块 './commands/ban.js' - |Discord Bot Error: Cannot find module './commands/ban.js' 运行测试用例时出现节点错误“找不到模块” - Node error 'Cannot find module' when running test case 制作不和谐机器人。 出现错误:找不到模块 'C:\Users\Michael\Desktop\Discord Bot' - Making discord bot. Getting Error: Cannot find module 'C:\Users\Michael\Desktop\Discord Bot' 找不到模块“节点:事件” - Cannot find module 'node:events' 使用Node JS运行Discord机器人时出错 - Error running a discord bot using node js 无法找到节点:使用 discord.js 的事件 - Cannot Find Node:Events with discord.js
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM