【发布时间】:2022-01-19 22:43:37
【问题描述】:
我最近从 discord.py 切换到了 discord.js,当我尝试运行机器人时出现错误
我看过很多教程并尝试了所有不同的方法来将库导入 VS Code,但它们都给出了一些错误
我现在要做的是:
const Discord = require('discord.js');
const client = new Discord.Client();
require('dotenv').config()
var prefix = '?'
var newprefix = ''
client.on('ready', () =>
{
console.log('Online')
})
当我输入“node main.js”时出现此错误:
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module 'C:\Users\username\OneDrive\Desktop\Bots\JSBot\main.js'
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
我相信我已经正确下载了库和其他依赖项,但即使我尝试其他方法,也会出现一些不同的错误。
我会做错什么?
【问题讨论】:
-
请发送您的目录屏幕。
-
您确定您将文件命名为
main.js而不是index.js或其他名称吗?
标签: javascript discord discord.js