I have no idea how to fix this error

I am a extremely new coder and I cannot seem to figure out the cause of this error. Any help would be appreciated.

  • C:\Users*\OneDrive\Desktop\DiscordBot\main.js
    e[90m at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)e[39m
    e[90m at Function.Module._load (internal/modules/cjs/loader.js:841:27)e[39m
    e[90m at Module.require (internal/modules/cjs/loader.js:1025:19)e[39m
    e[90m at require (internal/modules/cjs/helpers.js:72:18)e[39m
    at Object. (C:\Users\smoke\OneDrive\Desktop\DiscordBot\main.js:2:27)
    e[90m at Module._compile (internal/modules/cjs/loader.js:1137:30)e[39m
    e[90m at Object.Module._extensions…js (internal/modules/cjs/loader.js:1157:10)e[39m
    e[90m at Module.load (internal/modules/cjs/loader.js:985:32)e[39m
    e[90m at Function.Module._load (internal/modules/cjs/loader.js:878:14)e[39m
    e[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)e[39m {
    code: e[32m’MODULE_NOT_FOUND’e[39m,
    requireStack: [ e[32m’C:\Users\
    *\OneDrive\Desktop\DiscordBot\main.js’e[39m ]
    }

Hey @Zifyl, welcome to the Glitch Forums!

Can you go to your terminal and run npm install, as it looks like you don’t have a package you are requesting installed.

https://gyazo.com/a68d7ccf48a1caf16e469efbb40e39dd This is what happens.

Well, If there are no errors when installing Packages from package.json
Looks like: npm error discord-bot@1.0.0: ERROR_MESSAGE

It should be good.

What does your package.json look like?

{

“name”: “discord-bot”,

“version”: “1.0.0”,

“description”: “”,

“main”: “main.js”,

“scripts”: {

"test": "echo \"Error: no test specified\" && exit 1"

},

“author”: “***”,

“license”: “ISC”,

“dependencies”: {

"@discordjs/opus": "^0.3.2",

"config.json": "0.0.4",

"discord.js": "^12.3.0",

"ytdl-core": "^3.2.1"

}

}

Can you run node -v? so I can add the version of node your your package.json please?

The version that it outputted is v12.18.3

Ok
(20char 20char 20char)

The quotes have to be like "" not “”, so I fixed that (because JSON validators were going crazy over that!)
I also formatted and shortened the JSON file.
Also, I don’t think node v12.18.3 is available on glitch because Glitch’s help article said these were the versions on Glitch (someone correct me if I am wrong)

So here you go!

{
  "name": "discord-bot",
  "version": "1.0.0",
  "description": "Zifyl's amazing Discord bot!",
  "main": "main.js",
  "scripts": {
    "test": "echo No test specified!",
    "start": "node main.js"
  },
  "engines": {
    "node": "12.18.3"
  },
  "author": "Zifyl",
  "license": "ISC",
  "dependencies": {
    "@discordjs/opus": "^0.3.2",
    "config.json": "0.0.4",
    "discord.js": "^12.3.0",
    "ytdl-core": "^3.2.1"
  }
}

Nope, still getting the exact same error message even after changing it.

Also I am using visual studio code, I just put my code into glitch’s project feature.

Do you have a antivirus? Disable it, rerun the command and re-enable the antivirus.
My old antivirus blocked node from running

Also try running it using Glitch’s console
https://glitch.happyfox.com/kb/article/48-i-ve-got-mad-skillz-i-need-a-terminal-command-line-console/

Ok I disabled antivirus, now this is the only error.

What does main.js look like?

const Discord = require(‘discord.js’);

const { prefix, token } = require(’./c onfig.json’);

const fs = require(‘fs’);

const client = new Discord.Client();

client.commands = new Discord.Collection();

const commandFiles = fs.readdirSync(’./commands’).filter(file => file.endsWith(’.js’));

for (const file of commandFiles) {

const command = require(`./commands/${file}`);

// set a new item in the Collection

// with the key as the command name and the value as the exported module

client.commands.set(command.name, command);

}

client.once(‘ready’, () => {

console.log('Ready!');

});

client.on(‘message’, message => {

if (!message.content.startsWith(prefix) || message.author.bot) return;

const args = message.content.slice(prefix.length).trim().split(/ +/);

const command = args.shift().toLowerCase();

client.commands.get('ping').execute(message, args);

client.commands.get('avatar').execute(message, args);

});

[client.login(token removed)];

Do not share your token publicly. Regenerate it immediately, since people can use it maliciously.

Oh yeah I forgot
(20Char)

config.json has a space in it.

And please don’t show this on the internet! This could allow people to log in as your bot and get your Discord account/bot banned!

Please regenerate it using this method by @Medium/Brandon Russel

How to regen your bot token

If your token has been posted somewhere it needs to be regenerated immediately . Go to the Discord developer portal, select your app, select the “Bot” section, and click “Regenerate”. If you keep a leaked token valid then anyone using it could potentially destroy your servers and ruin your bot

I fixed the space in it(There was another error before.)