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

Viewed 2814

Getting this error on upgrading react-scripts from 3.4.1 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? I would appreciate your answers!

1 Answers

The problem is it is trying to find a default export for "name" in your JSON file. For this use:

  1. import (jsonfilename ) from '../(filename).json'

Now you will be able to access the data deconstructing

  1. const {any value you want to access from the JSON file} = (JSON file name).json; //keep the rest of the code the same See the image if you didn't understand.

enter image description here

Now your problem must be Solved. Thanks.
#HappyCoding

Related