WARN export ‘default’ (imported as ‘content’) was not found

Hello Friends 🙏, today while I was setting up a new React project from scratch without using create-react-app and after doing all the required steps when I compiled the React App, I got below warning😮:

export ‘default’ (imported as ‘content’) was not found in ‘!!../node_modules/mini-css-extract-plugin/dist/loader.js!../node_modules/css-loader/dist/cjs.js!../node_modules/sass-loader/dist/cjs.js!./styles.scss’ (module has no exports)

So basically it is related to mini-css-extract-plugin, we have used it to extract the styles from the project to a style file.

Below is the configuration I had done to setup the CSS loaders along with this plugin

And as you can see in the warning there is a red color text (module has no exports), it made me think is it related to the way we are importing the css (i.e. directly importing without naming it as SCSS files do not use export syntaxes).

After some googling 🔍 , I found out that there is an option in mini-css-extract-plugin “esModule” and by setting it false warnings were not coming up again😁 🥳🥳.
So basically esModules are ECMAScript standard for working with modules. And modules is a JS file having variables and methods which must be exported, so that other files can import those methods and reuse it.
And in our case, as we don’t export styles as its not a js file and can be imported directly in the component, we have to turn off the esModule flag for the mini-css-extract plugin.

Do you know anyother way to resolve this issue, feel free to comment.


Leave a Comment

Your email address will not be published.