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

203
Visualizações
Webpack 5 Error: Should not import the named export 'foo' (imported as 'bar') from default-exporting module

After upgrading to Webpack 5, I'm now encountering this error:

./node-modules/@fizz/my-library/components/MyComponent/MyComponent.js:97:19-39 - Error: Should not import the named export 'foo' (imported as 'bar') from default-exporting module (only default export is available soon)

The issue occurs in an imported library that I cannot modify. The problematic import is this:

import { foo as bar } from '../ParentComponent.css.json';

ParentComponent.css.json looks like this:

{
    "foo": { 
        "a": 1,
        "b": 2,
        "c": 3
    },
    ...
}

I have the following in tsconfig.json:

"compilerOptions": {
    "module": "commonjs",
    "moduleResolution": 'node",
    "target": "es2015",
    "allowSyntheticDefaultImports": true,
    "resolveJsonModule": true,
    "esModuleInterop": true,
    ...
}

Any ideas on how I can resolve this error? I have tried deleting node_modules and package-lock.json but have had no success.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Problem that you are facing is related to how modules are built in JavaScript.

You can export a default module from a file, or a named one. Difference looks like that:
export default myFunction vs export myFunction
The obvious conclusion is that a particular file can not contain more than one default export.

So to import this file, you actually can name it anyway you want it to, as no matter what you will call it, JavaScript will take the object exported by default and will reference to it correctly.

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