Syntax Error, unexpected token m
I need help
17 Replies
• What's your exact discord.js
npm list discord.js
and node node -v
version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.my node version is v18.15.0
node index.js
node:internal/modules/cjs/loader:388
throw e;
^
SyntaxError: Error parsing C:\Users\HP\Desktop\astralt\package.json: Unexpected token m in JSON at position 254
at parse (<anonymous>)
at readPackage (node:internal/modules/cjs/loader:376:42)
at readPackageScope (node:internal/modules/cjs/loader:412:19)
at shouldUseESMLoader (node:internal/modules/run_main:47:15)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:24)
at node:internal/main/run_main_module:23:47 {
path: 'C:\Users\HP\Desktop\astralt\package.json'
}
Node.js v18.15.0
when i try to run the bot, this error pops up
Your
package.json
is not in valid JSON formatHow to fix it? Sry I'm new to that
Considering that you didn't share your code, all I can do is show you how how it's supposed to look: https://www.json.org/json-en.html
I would send the code, but i dont want to reveal token
You could just replace it with a placeholder before you send the message in discord
Also, you shouldn't have a token in your package
I didnt mean package
Nvm
package.json {
"name": "astralt",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo "Error: no test specified" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"discord.js": "^14.8.0"
}
}
Is that what your code looks like, or does it look like this:
If the former, then you're not escaping the quotes in your test script
If the latter, then it works fine for me
This
Idk where's the problem in index.js
Visual Studio Code doesn't show any error
I will post index.js without token
const { Client, Events, GatewayIntentBits } = require('discord.js');
const { token } = require('./config.json');
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
client.once(Events.ClientReady, () => {
console.log('Ready!');
});
client.login(token);
Where's the problem?
Bump
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
There
Squid said it looks fine
Then idk where is the problem
I also sent index.js here
I think I did everything right, i don't know why it prevents me from running the bot
Did you find any mistakes in both package.json and index.js?
So should I show node modules?
I saved it with ctrls
Ok tysm