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

367
Visualizações
NextJS Use 'import' with ESM packages instead

I'm getting this error:

Module not found: ESM packages (remark) need to be imported. Use 'import' to reference the package instead. https://nextjs.org/docs/messages/import-esm-externals
  2 | import path from 'path'
  3 | //import matter from 'gray-matter'
> 4 | import remark from 'remark'
    |                           ^
  5 | import html from 'remark-html'

Even though the module is being imported correctly.

When I change it to a name which doesn't exist I get:

./lib/posts.js:4:28
Module not found: Can't resolve 'remarke'
  2 | import path from 'path'
  3 | //import matter from 'gray-matter'
> 4 | import remark from 'remarke'
    |                            ^
  5 | import html from 'remark-html'

So I know that it is imported.

I also tried adding this to next.config.js:

experimental: {
        esmExternals: "loose",
    },

But then I get this error:

TypeError: (0 , _remark).default is not a function

This has something to do with the switch to ESM module of the remark library.

Does anyone know what I can do to get rid of this error?

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