Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

453
Vistas
Error [ERR_REQUIRE_ESM]: require() of ES Module /app/node_modules/got/dist/source/index.js from /app/commands/Image/meme.js not supported

Code:

const { EmbedBuilder } = require("discord.js");
const got = require("got");

module.exports = {
  name: "meme",
  description: "Shows an image of a meme!",
  run: async (client, message, args) => {
      got("https://www.reddit.com/r/memes/random/.json").then(response => {
      const [list] = JSON.parse(response.body);
      const [post] = list.data.children;

      const permalink = post.data.permalink;
      const memeUrl = `https://reddit.com${post.data.permalink}`;
      const memeImage = post.data.url;
      const memeTitle = post.data.title;
      const memeUpvotes = post.data.ups;
      const memeNumComments = post.data.num_comments;
      
      const memeEmbed = new EmbedBuilder()
         .setTitle(`${memeTitle}`)
         .setURL(`${memeUrl}`)
         .setColor("Random")
         .setImage(memeImage)
         .setFooter({ text: `👍 ${memeUpvotes} | 💬 ${memeNumComments}` });
      message.reply({ embeds: [memeEmbed] });
    });
  }
};

Error:

const got = require("got");
            ^
Error [ERR_REQUIRE_ESM]: require() of ES Module

/app/node_modules/got/dist/source/index.js from /app/commands/Image/meme.js not supported.

I’m not too sure what this ESM is, I’ve never dealt with it before, therefore I don’t know what to do to fix this.

Kinda think it’s got to do something with the package itself, but like I said I’m clueless as I’ve never had this error before.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

got is a native ESM and no longer provides a CommonJS export.

Use ESM

To use the latest version, you'll have to convert to ESM:

  1. you need to add "type": "module" to your package.json
  2. replace all require()s and module.exports with import and export

Downgrade got

Another option is to downgrade got to v11.8.3 as it's pretty stable:

You can run npm i got@11.8.3 in your console.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda