我正在制作 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' ]}文件结构:屏幕
1 回答
犯罪嫌疑人X
TA贡献2080条经验 获得超4个赞
你可以试试Array.map
commandFiles.map(file => () {
const commands = require(`./commands/${file}`)
bot.commands.set(commands.name, commands)
})
确保您的文件存在!
添加回答
举报
0/150
提交
取消