简体   繁体   English

如何修复此“缺少模块”错误(node.js/discord.js)?

[英]How can I fix this "missing module" error (node.js/discord.js)?

Here's the code, I was trying to run a discord bot file.这是代码,我试图运行 discord 机器人文件。

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

Error: Cannot find module 'node:events'
Require stack:
- /path/bot/node_modules/discord.js/src/client/BaseClient.js
- /path/bot/node_modules/discord.js/src/index.js
- /path/bot/index.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> (/path/bot/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: [
    '/path/bot/node_modules/discord.js/src/client/BaseClient.js',
    '/path/bot/node_modules/discord.js/src/index.js',
    '/path/bot/index.js'
  ]
}

What module would be missing?会缺少什么模块? I haven't really fiddled around with node.js much, or discord.js, so I have no idea what could be going wrong.我并没有真正摆弄 node.js 或 discord.js,所以我不知道可能出了什么问题。 Plz help:)请帮助:)

If you're using discord.js version 13+ you need to upgrade to Node.js version 16.+.如果您使用的是 discord.js 版本13+ ,则需要升级到 Node.js 版本 16.+。 Otherwise you won't be able to run the bot否则你将无法运行机器人

Simply visit Node.js and either install the LTS (recommended) version or the current只需访问Node.js并安装 LTS(推荐)版本或当前

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM