Error: Cannot find module './config.json' discord.js

Hello, i was coding my 8ball command module but it don’t load. It gives me this error in the log:
Unable to load command 8ball.js: Error: Cannot find module './config.json'

Here is the code:

const Discord = require("discord.js");
const botconfig = require("./config.json");

function randomIntInc(low, high) {
  return Math.floor(Math.random() * (high - low + 1) + low);
} = async (client, message, args) => {
  var rnd = randomIntInc(1, 5);
  if (rnd === 1) {
    const embed1 = new Discord.RichEmbed()
      .setDescription(':8ball: 8ball')
      .addField(args.join(" "), 'Não');
  } else if (rnd === 2) {
    const embed2 = new Discord.RichEmbed()
      .setDescription(':8ball: 8ball')
      .addField(args.join(" "), 'Não é provavel');
  } else if (rnd === 3) {
    const embed3 = new Discord.RichEmbed()
      .setDescription(':8ball: 8ball')
      .addField(args.join(" "), 'Talvez');
  } else if (rnd === 4) {
    const embed3 = new Discord.RichEmbed()
      .setDescription(':8ball: 8ball')
      .addField(args.join(" "), 'Provavelmente');
  } else if (rnd === 5) {
    const embed3 = new Discord.RichEmbed()
      .setDescription(':8ball: 8ball')
      .addField(args.join(" "), 'Sim');


exports.conf = {
  enabled: true,
  guildOnly: false,
  aliases: ["8"],
  permLevel: "User"
}; = {
  name: "8ball",
  category: "Diversão",
  description: "Mostra uma resposta negativa ou positiva a uma questão.",
  usage: "8ball [pergunta]"

MOD EDIT: formatting

It sounds like it can’t find a file called config.json at the location you’ve specified. Check there is a file with that name at that relative path. If you’re unsure, let us know the project name and we’ll take a look.

From the looks of the code, you’re using a command handler.

Where you’re defining the botconfig variable, replace it with the following:

const botconfig = require("../config.json");

The reason why it throws this error is because you’re trying to direct it to the folder that your commands are in and the file isn’t there.

For example:
./ - Inside the directory.
../ - Outside the directory.

I hope this helps!

It didn’t worked. Now the log says:
Unable to load command 8ball.js: Error: Cannot find module ‘…/config.json’

Now how do I solve this?

EDIT: Oh. And for some reason, config.json file isn’t in the glitch directory, but the system uses it! How is this possible?

I think the problem is actually that there isn’t a file there, and your project’s not using the file that’s not there.

If you care to share your project name someone might be able to offer some more specific suggestions.

Give me access to your project and I’ll help…

Here is the github repository:

EDIT: The config.json still not there!

You should create a config.json since there is none, create one. Somewhere along the way there is something in your code that requires data from the config.json file.

Also if the config isn’t in a folder, try adding another period. So its like so:


Edit 2, guess it isn’t really anything discordjs related afterall

I’ve already tryed, but that isn’t working.

Finally I’ve found the problem! My config file was config.js and not config.json.
Thanks for the help anyways.