199

I got an error while creating a React application. How do I fix it?

Enter image description here

Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
Athif Saheer
  • 3,761
  • 3
  • 6
  • 11

6 Answers6

754

Try running this:

npx clear-npx-cache
richardec
  • 14,202
  • 6
  • 23
  • 49
ProgrammerS
  • 7,565
  • 2
  • 1
  • 2
  • 50
    This worked for me as well. I think this should be marked as the correct answer as it doesn't require forcing the latest version. – Patrick Haertel Dec 18 '21 at 19:08
  • 1
    This worked for me too. This issue happened even after a fresh install of node js. This fix worked like a charm. <3 – emkarachchi Jan 20 '22 at 15:08
  • 8
    I think we need to add more detail on why this work – alvseek Feb 02 '22 at 04:43
  • 2
    This fixed the issue for me. Thanks. – Mary Obiagba Mar 16 '22 at 01:06
  • 3
    This is the correct answer I tried to find more details. Based on the response from James L here: https://stackoverflow.com/questions/63510325/how-can-i-clear-the-central-cache-for-npx create-react-app is still in npx cache memory even though it is not installed globally so clearing the npx cache using the command above solves it. – BoyePanthera Mar 28 '22 at 14:34
  • 1
    this fixed my issue also, no idea why this is crashing. but thanks – DRProgrammer Mar 30 '22 at 14:46
  • If you don't want to download `clear-npx-cache`, run `rm -rf ~/.npm/_npx` instead – Codler May 30 '22 at 11:42
  • This didn't work for me, running `npm update npx` and then `npx create-react-app my-app` worked – ida Jun 02 '22 at 04:53
161

It's fixed. I do npx create-react-app@5.0.0 my-app.

Reference: Error while creating new React app ("You are running `create-react-app` 4.0.3, which is behind the latest release (5.0.0)")

Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
Athif Saheer
  • 3,761
  • 3
  • 6
  • 11
  • 2
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 15 '21 at 06:04
  • 6
    Do `npx clear-npx-cache` if you don't want to have to specify the cra version. – Michael Fulton Jan 02 '22 at 17:23
  • 3
    I could solve this problem using `npx create-react-app@latest my-app` – KitKat0225 Jan 10 '22 at 10:44
  • 1
    After clearing the cache for npm for almost 30 minutes to no avail. This worked for me. Sometimes you need to slow down and refocus. npx not npm – blakroku Jan 13 '22 at 14:38
67

npx clear-npx-cache worked for me.

Try npx clear-npx-cache to clear your npx cache and then running the npx create-react-app your-app.

Additionally, it might be worth trying to force the latest version with:

npx create-react-app@latest my-app --use-npm
48

It's solved. By using this code:

npx create-react-app@5.0.0 my-app

If it does not work, use this and try again:

Delete everything from C:\Users\your_pc_name\AppData\Roaming\npm-cache

This could be a local caching issue. Try the command npm cache clean --force using administrator mode in your terminal and then try again with the same command - npx create-react-app my-app.

richardec
  • 14,202
  • 6
  • 23
  • 49
Zain Alabdeen
  • 479
  • 1
  • 2
20

Follow this:

npm uninstall -g create-react-app

npm cache clean --force”

npm cache verify

npx create-react-app my-app

Juan Robledo
  • 309
  • 5
4

You are running create-react-app 4.0.3, which is behind the latest release (5.0.0).

We no longer support global installation of Create React App.

this works--npx create-react-app@5.0.0 my-app

Srinidhi S
  • 65
  • 2