简体   繁体   English

Discord.js:错误:更新到 v13 后“找不到模块‘node:events’”

[英]Discord.js: Error: "Cannot find module 'node:events'" after updating to v13

Today I updated my node version from 12.x to 17.1.0 and my discord.js to 13.3.1.今天我将我的节点版本从 12.x 更新到 17.1.0,将我的 discord.js 更新到 13.3.1。 The process of updating was successful but after I run my bot, it outputs the error:更新过程成功,但在我运行我的机器人后,它输出错误:

Error: Cannot find module 'node:events'
Require stack:
- /home/runner/rice-v13/node_modules/discord.js/src/client/BaseClient.js
- /home/runner/rice-v13/node_modules/discord.js/src/index.js
- /home/runner/rice-v13/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
    at Function.Module._load (internal/modules/cjs/loader.js:667:27)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/home/runner/rice-v13/node_modules/discord.js/src/client/BaseClient.js:3:22)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19

Also, I noticed that when I installed a new node version via shell it outputs a warning:此外,我注意到当我通过 shell 安装新节点版本时,它会输出警告:

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

I surfed this question on the Inte.net and only found answers like "You gotta have node version 16 or higher" but I actually have 17.1.0.我在 Inte.net 上浏览了这个问题,只找到了像“你必须有 16 或更高版本的节点”这样的答案,但我实际上有 17.1.0。

I see that you're using replit for your bot.我看到您正在为您的机器人使用 replit。 This error happens when your repl node version is not high enough.当您的 repl 节点版本不够高时会发生此错误。 You can fix that by using the NodeJS v16 Template ( https://replit.com/@RoBlockHead/NodeJS-16 ).您可以使用 NodeJS v16 模板 ( https://replit.com/@RoBlockHead/NodeJS-16 ) 来解决这个问题。 Just fork that repl template and move all your code there.只需 fork 那个 repl 模板并将所有代码移到那里。

Instead of:代替:

const client = new Discord.Client();

Type:类型:

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

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

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