Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

333
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda