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

648
Visualizações
Why am I getting a ReferenceError: AbortController is not defined in Discord.js v13?

Today (7.8.2021) Discord.js v13 has been released. So I upgraded my previous Discord.js installation with

npm i discord.js@latest

and then adapted my basic index.js file to this state (I followed the Discord.js Guide):

const { Client, Intents } = require("discord.js");

const client = new Client({
  intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES],
});

client.once("ready", () => {
  console.log("Ready!");
});

client.login("my-token");

However when I try to run my code I keep getting this error:

$ node .

(node:11216) UnhandledPromiseRejectionWarning: ReferenceError: AbortController is not defined

at RequestHandler.execute (C:\pathTo\node_modules\discord.js\src\rest\RequestHandler.js:172:15)

I've been working with Discord.js since 2018, hence I was astonished that I was having trouble with the new release. Is this an issue with the Discord.js v13 library? If not how can I fix the error?

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

The Issue:

One of the prerequisites for using Discord.js v13 is that you need to use NodeJS v16.6 or higher (emphasis mine):

v13 requires Node 16.6 or higher to use, so make sure you're up to date. To check your Node version, use node -v


The Fix:

The fix is to update your node version, you can confirm your current node version by running node -v. There are a variety of different ways to update node, one way is to run the following commands if you're using Linux / iOS:

> npm install -g n
> n latest

The first command installs the command-line interface n, and then the second uses n to update to the latest stable version of node. If you're on Windows, you can install NVM as outlined in this answer by pradeek.

Note for Heroku users:

Once you have followed the above steps to update your node version, you might then be required to update your package.json file by adding/updating the engines:

"engines": {
  "node": "16.x"
}

Why this broke in v13?:

A few versions ago of discordjs, a feature was added that aborts requests that take too long (longer than 15 seconds). In order to achieve this functionality, they were previously using the node package abort-controller. However, now that nodejs has evolved, it now has its own AbortController global without the need to require an external package. Discord.js v13 now relies on this global as they're no longer using the abort controller package. In order to use the AbortController global provided by nodejs, you need to be using node v15 or higher - however, as recommended by the discord.js guide, you should be using v16.6+ to enable support for other features it may use.

over 4 years ago · Santiago Trujillo Relatório

0

If you don't want to install node.js v16 in all your system, and just add it in your bot's project, you can do:

npm install node@16.6.1 --save-exact

And it will run.

over 4 years ago · Santiago Trujillo Relatório

0

N, the updater used in the solution, doesn't work for Windows operating systems. If you use Windows there is still a way to update. Go to the Node.JS installation website

If you go there manually without clicking the link I provided, you will need to switch from the LTS option to Current. as seen here

^ as seen here

Choose the MSI installer and the architecture of which your old Node.JS version was installed with.

If you don't know the architecture of which your old Node.JS version was installed with you can check by checking if the nodejs folder is in "C:/Program Files" or "C:/Program Files (x86)"

Then just install Node.JS as if it was the first time.

Enjoy!

over 4 years ago · Santiago Trujillo 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