错误:找不到模块“./commands/0”

我正在制作 aa discord bot 并且出现以下错误,它显示以下错误。


internal/modules/cjs/loader.js:969

  throw err;

  ^


Error: Cannot find module './commands/0'

Require stack:

- /home/karthik/VisualStudioCode/Projects/discord-bot/src/bot.js

    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)

    at Function.Module._load (internal/modules/cjs/loader.js:842:27)

    at Module.require (internal/modules/cjs/loader.js:1026:19)

    at require (internal/modules/cjs/helpers.js:72:18)

    at Object.<anonymous> (/home/karthik/VisualStudioCode/Projects/discord-bot/src/bot.js:12:22)

    at Module._compile (internal/modules/cjs/loader.js:1138:30)

    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)

    at Module.load (internal/modules/cjs/loader.js:986:32)

    at Function.Module._load (internal/modules/cjs/loader.js:879:14)

    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) {

  code: 'MODULE_NOT_FOUND',

  requireStack: [ '/home/karthik/VisualStudioCode/Projects/discord-bot/src/bot.js' ]

}

文件结构:屏幕


呼唤远方
浏览 108回答 1
1回答

犯罪嫌疑人X

你可以试试Array.mapcommandFiles.map(file => () {&nbsp; &nbsp;const commands = require(`./commands/${file}`)&nbsp; &nbsp;bot.commands.set(commands.name, commands)})确保您的文件存在!
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript