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

22

70

I am getting this create React app error again and again even after doing the uninstall part.

npm uninstall -g create-react-app

up to date, audited 1 package in 570ms

found 0 vulnerabilities

npx create-react-app test-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.0).

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/

C:\>npm --version
8.3.0
C:\>node --version
v16.13.0

How can I fix this?

Chiller answered 15/12, 2021 at 4:34 Comment(0)
S
173

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

Also have a look at this answer on clearing the cache.

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

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

Streamliner answered 15/12, 2021 at 4:45 Comment(2)
your second command work but I don't get that, why this error I got ?Gesticulate
In my case after running 'npx create-react-app' there was a notice about new major version of npm in there terminal. I use 'npm install -g [email protected]' (x need to be replaced with the shown version in the notice ). after that I run 'npx create-react-app' it worked.Biggs
R
21

I have resolved with the following steps:

  1. npm uninstall -g create-react-app

  2. npx clear-npx-cache

  3. npx create-react-app myapp

Roi answered 22/12, 2021 at 5:12 Comment(0)
A
12

Solution 1: Force to the latest version

Just try to run the create command with force to the latest version. Just like this:

npx create-react-app@latest_version my-app --use-npm

And the latest version is 5.0.0 so just try this command:

npx [email protected] my-app

Now, your error must be solved.

Solution 2: Clear the cache

You just need to clear your cache and then you can create a new React project. First of all, clear the cache by running this command:

npx clear-npx-cache

If it does not work, use this and try again: Delete everything from this path.

C:\Users\Your_user_name\AppData\Roaming\npm-cache

On macOS (and likely Linux), it’s ~/.npm/_npx. You can drop it with:

rm -rf ~/.npm/_npx

Or try the command npm cache clean --force using administrator mode in your terminal. Now, just rerun your create command.

npx create-react-app your-app

Solution 3: Run this command

Just run this command one by one.

  1. npm uninstall -g create-react-app
  2. npm cache clean --force
  3. npm cache verify
  4. npx create-react-app my-app
Amputee answered 26/12, 2021 at 16:44 Comment(1)
For me this worked with create-react-app@latest, didn't work with create-react-app@latest_versionGlow
O
4

You will have to clear the npx cache to make it work.

You can locate the location of the folder where create-react-app is installed using npm ls -g create-react-app.

Also, to clear the cache, refer to this answer in How can I clear the central cache for `npx`?

Overboard answered 15/12, 2021 at 4:44 Comment(1)
Thanks for your comment Sawan, yes clearing the cache did resolve my issue.Chiller
C
3

I have solved this problem by running

$ npm uninstall -g create-react-app

then

$ npx clear-npx-cache

then

$ npm install -g [email protected]

and then finally it was able to use:

$ npx create-react-app my-app
Conchoid answered 19/2, 2022 at 10:7 Comment(0)
C
3

Simply doing npx create-react-app@latest my-app-name worked for me.

Casilde answered 10/9, 2022 at 23:24 Comment(0)
L
2

(npx [email protected] my-app) worked like a charm and its also much faster now then old react js

Leghorn answered 17/12, 2021 at 7:38 Comment(0)
C
2

I followed the above suggestions but it didn't solve my problem. Below steeps solved my problem

1- Learn npm cache folder path:
npm cache verify
This gives you npm cache folder path: Cache verified and compressed (~\AppData\Local\npm-cache_cacache)

2- Go to"..\npm-cache" folder and delete everything

3- Cerate your project:
npx create-react-app my-app

Counterman answered 18/12, 2021 at 20:39 Comment(0)
A
2

I tried both and they all works fine. You can try any of them.

npx [email protected] my-app or npx clear-npx-cache

Aribold answered 22/12, 2021 at 6:34 Comment(0)
G
1

I got same issue and I fixed it by running the following commands:

npx clear-npx-cache
npm cache verify

Go to"..\npm-cache" folder that you get its path from previous command and delete everything

npm install -g [email protected]
npx create-react-app your_app_name
Glaciate answered 4/1, 2022 at 15:10 Comment(0)
D
1

I was having the same problem and no matter what I tried (i.e. clearing cache, uninstalling -g create-react-app, etc..) nothing worked.

I had to use:

$ npm uninstall -g create-react-app

and

$ npm uninstall create-react-app

and then I was able to use:

$ npx create-react-app my-app

I know it seems simple but this was the only thing that worked for me.

Dx answered 5/1, 2022 at 0:24 Comment(0)
P
1

If you still receive the same error after trying the other answers solutions try the following:

Go to the path where npm install packages globally.

  • On macOS or Linux it's usually: /usr/local/lib/node_modules
  • On Windows: C:\Users\USER_NAME\AppData\Roaming\npm\node_modules

Search for create-react-app folder and delete it. You might need to delete create-react-app related files from parent folder:

  • /usr/local/lib/
  • C:\Users\USER_NAME\AppData\Roaming\npm\

You may also try the 'npm root -g' command to get the path, however, for me the returned path wasn't the correct one for some reason.

Perreault answered 20/1, 2022 at 18:1 Comment(0)
C
1

If you clear the cache with "npx clear-npx-cache", exit your code studio and relaunch it again. Then create your app. It works like charm. The studio code need to lose the session first and that is why we need to exit the ms-code first and relaunch.

Cockaleekie answered 22/3, 2022 at 14:23 Comment(0)
S
1

This command worked for me by clearing the npx cache

npx clear-npx-cache

Sadi answered 4/4, 2022 at 11:58 Comment(0)
I
0

I have resolved this issue with the following combination of commands
1. First clear the cache

npx clear-npx-cache

2. Now run this command, this will uninstall the old version, install the latest one and create a new app using npm

npm uninstall -g create-react-app && npm i -g npm@latest && npx create-react-app@latest my-app --use-npm
Insectivorous answered 22/3, 2022 at 3:35 Comment(1)
if it is same as an existing answer, you could have up voted itRazee
G
0

First update node to the latest version.download the package from website and reinstall it .then update npm.then try npx create-react-app@latest appname.

Goncourt answered 11/6, 2022 at 17:56 Comment(0)
A
0

If you've previously installed create-react-app globally via npm install -g create-react-app, uninstall the package using npm uninstall -g create-react-app or yarn global remove create-react-app to ensure that npx always uses the latest version.

https://create-react-app.dev/docs/getting-started/

Aisha answered 26/6, 2022 at 7:34 Comment(0)
C
0

This solution working for me

npm uninstall -g create-react-app
npx clear-npx-cache
npx create-react-app my-app
Cleek answered 3/8, 2022 at 10:40 Comment(0)
P
0

Current as of 07/31/2023. Install node js v.16 and everything will work

  1. Install NVM

  2. install node js v.16

nvm install 16

  1. Select the current version (16)

nvm use 16

  1. Building a React App

npx create-react-app my-app

Prichard answered 31/7, 2023 at 7:7 Comment(0)
E
-1

To clear a cache in npm, we need to run the npm cache clean --force command in our terminal:

npm cache clean --force
npx clear-npx-cache

clean: It deletes all data from your cache folder.

Epideictic answered 25/12, 2021 at 20:8 Comment(0)
P
-1

If you're using npm>5 and still getting this error. This might be you have installed old npm and then updated. Tried to clear the npm cache with the below command. It should work like charm.

npx clear-npx-cache
Pennypennyaliner answered 28/12, 2021 at 8:51 Comment(0)
L
-1

npx have cache, you can run rm -rf ~/.npm/_npx to clear cache

Lutyens answered 30/5, 2022 at 11:44 Comment(1)
This answer offers no new information not present in currently existing answersIdempotent

© 2022 - 2024 — McMap. All rights reserved.