I recently switched from discord.py to discord.js and i am having an error when i try to run the bot
I've watched a lot of tutorials and tried all the different ways I've found to import the library into VS Code but they all give some error
What I'm trying to do now is this:
const Discord = require('discord.js');
const client = new Discord.Client();
require('dotenv').config()
var prefix = '?'
var newprefix = ''
client.on('ready', () =>
{
console.log('Online')
})
And im getting this error when i type "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: []
I believe I have downloaded the library and other dependencies correctly, but even if I try other methods some different error always comes up.
What would I be doing wrong?
The issue lies in that the file you're trying to run is not existent in the current directory. Ensure that your primary file is named main.js and that your terminals directory is set to the directory which includes main.js while running node main.js