0

I'm trying to put some information into a config folder, but for some reason whenever I try to run index.js, i get this error:

SyntaxError: C:\Users\eidhn\OneDrive\Desktop\dionysus\config.json: Unexpected token / in JSON at position 0
    at parse (<anonymous>)

the relevant code is here:

// require the config file
const { prefix, token } = require(`./config.json`);
// require fs, node's native file system module
const fs = require('fs');
// require the discord.js module
const Discord = require('discord.js');
// create a discord client
const client = new Discord.Client();
// a class that extends the map() function
client.commands = new Discord.Collection();

I've tried surrounding the ./config.json with single quotes, double quotes, or backticks, but nothing works.

They're right next to each other, in the same file, and i don't understand what's happening.

EDIT: this here is my json file

// storing data
{
    "prefix": "%",
    "token": "my token"
}

there is nothing else in the folder

EDIT: Thanks to commenters below, I didn't realise you couldn't use comments in .json files

blurfus
  • 13,485
  • 8
  • 55
  • 61

0 Answers0