【发布时间】:2021-11-26 06:03:39
【问题描述】:
我刚刚在 Replit 上启动了 Discord.JS。 它遵循 FreeCodeCamp 在https://www.freecodecamp.org/news/create-a-discord-bot-with-javascript-nodejs/ 上的教程
但是当我运行代码时它告诉我运行:
const Discord = require("discord.js")
const client = new Discord.Client()
client.on("ready", () => {
console.log(`Logged in as ${client.user.tag}!`)
})
client.on("message", msg => {
if (msg.content === "ping") {
msg.reply("pong");
}
})
client.login(process.env.TOKEN)
它告诉这个错误:
Error: Cannot find module 'node:events'
Require stack:
- /home/runner/Omega-Flowey-JS-Test/node_modules/discord.js/src/client/BaseClient.js
- /home/runner/Omega-Flowey-JS-Test/node_modules/discor
Error: Cannot find module 'node:events'
Require stack:
- /home/runner/Omega-Flowey-JS-Test/node_modules/discord.js/src/client/BaseClient.js
- /home/runner/Omega-Flowey-JS-Test/node_modules/discord.js/src/index.js
- /home/runner/Omega-Flowey-JS-Test/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/Omega-Flowey-JS-Test/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
谁能告诉我什么错误?我是 Discord.JS 的新手,所以我不知道有什么错误。
【问题讨论】:
-
您在运行
npm install时是否遇到错误? -
我不知道,当我启动它时,它只是立即给出了那个错误。就像程序只是不想尝试运行并且只是给出错误一样
标签: javascript node.js discord discord.js