Create React App cannot create new applications: No longer support global installation

Sometimes, Create React App will produce an error when you try to create a new application using npx or npm init.

When I try to create a new React application this morning, I got a message saying that I can’t create a new React app as follows:

$ npx create-react-app my-app         

Need to install the following packages:
  create-react-app
Ok to proceed? (y) y

You are running `create-react-app` 4.0.3, which is 
behind the latest release (5.0.1).
We no longer support global installation of Create React App.

Please remove any global installs with one of the following commands:
- npm uninstall -g create-react-app
- yarn global remove create-react-app

The latest instructions for creating a new app can be found here:
https://create-react-app.dev/docs/getting-started/

npm ERR! code 1
npm ERR! path /Users/nsebhastian/Desktop/DEV
npm ERR! command failed
npm ERR! command sh -c create-react-app "my-app"

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/nsebhastian/.npm/_logs/2022-05-09T02_20_51_340Z-debug.log

The error above happens because Create React App thinks I have an older version of CRA installed on my computer.

But when I run the two uninstall commands above, I don’t see any package being removed from my npm modules:

$ npm uninstall -g create-react-app

up to date, audited 1 package in 97ms

found 0 vulnerabilities

$ yarn global remove create-react-app
yarn global v1.22.17
[1/2] 🗑  Removing module create-react-app...
error This module isn't specified in a package.json file.
info Visit https://yarnpkg.com/en/docs/cli/global 
for documentation about this command.

I didn’t find create-react-app package either when I ran npm list command:

$ npm list -g

/Users/nsebhastian/.nvm/versions/node/v16.13.0/lib
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

If you receive the same error, then the problem happens because npm keeps a cache of the Create React App that you’ve installed previously.

When you try to install CRA from npx as shown below:

$ npx create-react-app my-app
Need to install the following packages:
  create-react-app
Ok to proceed? (y) y

Then npm will try to install the package using the cache stored from your previous install.

To resolve this error, you need to clear the cache of npx with the following command:

npx clear-npx-cache

If you’re using npm init, then try to clear the npm cache with the following command:

npm cache clean --force

Once you clear the npx or npm cache, you should be able to use create-react-app to create new applications again.

And that’s how you fix the We no longer support global installation of Create React App error.

I hope this tutorial has been helpful for you 👍

Take your skills to the next level ⚡️

I'm sending out an occasional email with the latest tutorials on programming, web development, and statistics. Drop your email in the box below and I'll send new stuff straight into your inbox!

No spam. Unsubscribe anytime.