制作不和谐机器人时如何修复找不到模块错误?

How to fix cannot find module error when making discord bot?

enter image description here enter image description here

enter image description here

我是编码新手,不知道为什么在尝试让我的机器人联机时会弹出此错误。两张图都在上面

您的问题出在您的 package.json 文件 运行 终端中的代码 npm init 并全部填写。

如果您已经有,那么它正在寻找会说 "main": "index.js",

的行

看起来像这样(你的会有所不同,所以不要复制和粘贴):

{
  "name": "gh0st",
  "version": "1.0.0",
  "description": "Whosebug testing bot",
  "main": "ghost.js",
  "scripts": {
    "start": "node ghost.js"
  },
  "author": "Gh()st",
  "license": "ISC",
  "dependencies": {
    "@discordjs/rest": "^0.3.0",
    "discord-modals": "^1.3.5",
    "discord.js": "^13.6.0",
    "fs": "^0.0.1-security",
    "mysql": "^2.18.1",
    "node-cron": "^3.0.0"
  }
}