create-react-app icon indicating copy to clipboard operation
create-react-app copied to clipboard

Should not import the named export 'name' (imported as 'packageName') from default-exporting module (only default export is available soon)

Open RambabuPatina opened this issue 3 years ago • 16 comments

Getting this error on upgrading react-scripts from 4.0.3 to 5.0.0. I have checked in code, import and export statements seems fine and not importing package.json in any file, but could not able to build it. Should not import the named export 'name' (imported as 'packageName') from default-exporting module (only default export is available soon) How to debug in which file it has errors. Any idea/suggestions to resolve it?

RambabuPatina avatar Mar 08 '22 15:03 RambabuPatina

got the same issue, any idea

hlpupo avatar May 12 '22 02:05 hlpupo

same

InfinityLoopLabs avatar Jun 18 '22 09:06 InfinityLoopLabs

We're also affected by the same issue, and it is referencing an area of the code where imports are done as import * as name from 'path\to\file.json'. The reason we were doing it like this is that's a JSON file.

One potential workaround for us is to change the import statement to be import name from 'path\to\file.json'.

However, this is not the official answer to this. I'm just trying to help.

sorinpav avatar Jul 01 '22 12:07 sorinpav

Same

mohqarmout avatar Aug 06 '22 01:08 mohqarmout

same

0123cf avatar Jan 09 '23 07:01 0123cf

same

NaumanDurani avatar Feb 12 '23 13:02 NaumanDurani

same

juanhelbert avatar Feb 14 '23 14:02 juanhelbert

This is too late but I am adding it because it will help some others. First of all we should know what is importing from default-export module. For eg we should add curly braces for importing any element from react-router-dom or react redux (i-e import {Link} from react-router-dom). If you try to import some other random element using curly braces which is not a part of react router dom or react redux or any default export module it throws error(for eg say import {images} from '../../assets/images.png'). Here what is image?? react doesn't gives any module like image right! So it throws error. This is an example. Relate this issue with your problem. So what I am trying to say is you are trying to import the element in an improper way, So the React thinks that it is produced by default export module. It is not about the version, its the way you imported the file. Try adding the exact location and verify the import statement once. It may or may not help but I hope this will help some people :)

AravindS1306 avatar Feb 21 '23 15:02 AravindS1306

This is too late but I am adding it because it will help some others. first you have to import the file like import bglogo from "../data/data.json" then create a variable const logo=bglogo.logo; the use it as logo

Imran0808 avatar Mar 17 '23 13:03 Imran0808

same

BinQi avatar May 22 '23 08:05 BinQi

same

liuyuanyuannumberone avatar Jul 02 '23 06:07 liuyuanyuannumberone

Thanks for your E-mail. I will reply to it at my earliest convenience.Have a nice day~

BinQi avatar Jul 02 '23 06:07 BinQi

Instead of importing the file this way import {SignUp} from './Users/SignUp'; , do it this way import SignUp from './Users/SignUp'; Basically, remove the curly braces "{}"

SHISIA avatar Oct 18 '23 06:10 SHISIA

If I remove the curly braces I cant use .map on it. How is everyone else solving this issue?

hibatariq avatar Nov 24 '23 20:11 hibatariq

Instead of importing the file this way import {SignUp} from './Users/SignUp'; , do it this way import SignUp from './Users/SignUp'; Basically, remove the curly braces "{}" it Works

Eshant4 avatar Feb 15 '24 07:02 Eshant4

fuck you

Sa1dakbar09 avatar Aug 01 '24 11:08 Sa1dakbar09