I have an ejected create-react-app project. I am getting this error after updating it to webpack 5. It was working fine with webpack v4.41.5
OS: MacOS Catalina 10.15.7
node: v10.23.0
Error: Should not import the named export 'version' (imported as 'version') from default-exporting module (only default export is available soon).
Change the following
import { version } from '../../package.json';
to something like
import packageInfo from '../../package.json';
And then change your access from something like
version,
or
version: version,
to
version: packageInfo.version,
As noted in the comments, there may be cases where you do not want to expose your entire package.json
file in the client code.
You should also add
"allowSyntheticDefaultImports": true,
to the compileroptions in the tsconfig.json
I solved my issue with the following:
import packageInfo from './package.json';
version = packageInfo.version;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With