Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

331
Views
discord.js SyntaxError: Unexpected token?

I'm doing the discord.js getting started bot but I always get this error: SyntaxError: Unexpected token? the error code i get

This is the code I used, actually just copy and paste from their tutorial just switched to dotenv for the token...

 // Require the necessary discord.js classes
require("dotenv").config();
const { Client, Intents } = require('discord.js');

// Create a new client instance
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });

// When the client is ready, run this code (only once)
client.once('ready', () => {
    console.log('Ready!');
});

// Login to Discord with your client's token
client.login(process.env.TOKEN);

These are the versions of discord.js and dotenv I'm using. Node version is 12.8.0

    "dependencies": {
    "discord.js": "^13.1.0",
    "dotenv": "^10.0.0"
  }

Already thanks for your help guys!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

So the first thing to note is that your error is coming from node_modules. That means that the code that is erroring is code that you've imported from npm to do something. Because it's not your code and rather third party code that probably works, that means that the error most likely has to do with either your version of that code or the way you're using that package is incorrect.

My best guess would be that it has to do with some advanced syntax that the package is using, but that errors on your machine because you have version incompatibility. I'd recommend updating your node version and trying again. Let us know if that fixes the problem!

Download latest node version: https://nodejs.org/en/download/

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!