Fixing Create React App Error: No valid exports main found
Are you having issues running your Create React App because you’re seeing a similar issue as this:
./src/index.css (./node_modules/css-loader/dist/cjs.js??ref--6-oneOf-3-1!./node_modules/postcss-loader/src??postcss!./src/index.css) Error: No valid exports main found for '/Users/jdoe/Sites/my-app/node_modules/colorette'
It may say colorette or normalize.css. Let me explain how this error message happened to me.
I was recently downloading someone’s React app, which happens to be using the Create React App tool.
npm i and followed up with
Then the error message above showed up.
This is how I fixed this problem.
Solution: Upgrade node version
At the time I was running Node version 13.17.0.
I upgraded to the latest version of Node, v14.7.0, to fix my problem.
I’m using Homebrew to manage my node versions.
You can do this process manually, or with Homebrew if you’re using MacOS, or you may do it with linuxbrew on Windows.
So I ran the following commands to upgrade on my Node version on mac:
$ brew update $ brew upgrade node
After my Node was upgraded, I ran the following commands to get the Create React App running.
$ rm -rf node_modules $ npm ci
I had to delete the node modules directory, and ran
npm ci to install the project with a clean slate.
I like to tweet about React and post helpful code snippets. Follow me there if you would like some too!