Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

191
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!