npx create-react-app prompting to globally uninstall non-existent create-react-app package?
Asked Answered
C

13

51

I am having problems with npx create-react-app involving global installs. My confusion arises because as far as I'm aware the create-react-app package is not installed on my machine.

Some Details:

I start a react project (with typescript template) as I have previously and recently done on this same machine a number of times:

npx create-react-app --template typescript .

I get this prompt from the terminal

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

I press y to confirm it's okay to proceed. (If I press n, the process terminates with the following error: npm ERR! canceled.) The terminal then displays the following message

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/

I run both suggested commands to uninstall create-react-app globally. npm goes smoothly:


npm uninstall -g create-react-app

up to date, audited 1 package in 179ms

found 0 vulnerabilities

the global yarn uninstall results with the following message:

remove create-react-app
yarn global v1.22.17
warning package.json: No license field
[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.

Finally I try to find if create-react-app exists on my machine with which create-react-app which results in create-react-app not found.

I'm not sure how else to address this issue.

Edit: Solution provided by Deepthi and Sators. I had to clear the npx cache which had stored an older version of create-react-app by using command:

npx clear-npx-cache

Chandelier answered 14/12, 2021 at 16:45 Comment(1)
G
31

You can try to locate the installed version by running:

npm ls -g create-react-app

You may also want to consider reading this post for removing/clearing the npx cache by using:

npx clear-npx-cache

Finally, another option is to ensure you are using the latest version of create-react-app by running:

npx create-react-app@latest --template typescript .
Graticule answered 14/12, 2021 at 16:47 Comment(3)
Clearing the npx cache did the trick for me. I'm in happy hacking territory again, much appreciated!!! – Chandelier
Hello, i'm having a similar issue, but with yarn create react-app i clean all my caches, and delete all the global installations, but the issue persists. Any idea why this could be happening? - btw, i cannot use v5.0.0 because my server is on Node 12 – Epileptic
You could try yarn create react-app@latest – Graticule
S
102

For something like this encountered: " You are running create-react-app 4.0.3, which is behind the latest release (5.0.0)."

Solution was :

>  npx clear-npx-cache

Then do:

> npx create-react-app your-app
Statesman answered 15/12, 2021 at 3:49 Comment(5)
Thank you! I tried everything from clearing npm cache to uninstalling and reinstalling node, finally this solution fixed it :) – Desrochers
Thanks! that command fixed my issue. – Moresque
this does works! please tick this answer – Sustentacular
I am running into stuck after running npx clear-npx-cache with node v14.16.0 and npm 6.14.11 on Windows 10 – Sialagogue
still working with npm 8.11.0 and node v16.15.1 ! Thank you ! – Classic
G
31

You can try to locate the installed version by running:

npm ls -g create-react-app

You may also want to consider reading this post for removing/clearing the npx cache by using:

npx clear-npx-cache

Finally, another option is to ensure you are using the latest version of create-react-app by running:

npx create-react-app@latest --template typescript .
Graticule answered 14/12, 2021 at 16:47 Comment(3)
Clearing the npx cache did the trick for me. I'm in happy hacking territory again, much appreciated!!! – Chandelier
Hello, i'm having a similar issue, but with yarn create react-app i clean all my caches, and delete all the global installations, but the issue persists. Any idea why this could be happening? - btw, i cannot use v5.0.0 because my server is on Node 12 – Epileptic
You could try yarn create react-app@latest – Graticule
B
12

The problem here is that the npx create-react-app is trying to install packages from an older version (4.0.3) while the latest version is (5.0.0).

You can simply clear the npx cache by using the following command:

npx clear-npx-cache

and then try to create a react app again using

npx create-react-app Your_project_name

Or

You can use npx with @latest to guarantee that you are running create-react-app along with the latest version:

npx create-react-app@latest Your_project_name

Or

you can install the latest react app modules locally in the working directory by using:

npm install create-react-app@latest

(This will create react modules in addition to package.json and package-lock.json in the working directory which will be depended on when installing the react app, so you can delete them after finishing the next step)

and then:

npx create-react-app Your_project_name

Boy answered 14/12, 2021 at 23:33 Comment(3)
Thanks @sanad-khamash. npx create-react-app@latest worked for me to ensure that I am running create-react-app latest version. – Hedveh
@Hedveh You're more than welcome sir. – Boy
npx create-react-app@latest Your_project_name worked for me – Cariotta
F
8

Apparently there is a problem with that version, I just have the same issue, but with the command

npx clear-npx-cache

It did the trick, then I've just run the

npx create-react-app proyect-name

And it works!

I think this is the same answer as above, but well, there you go.

Fever answered 15/12, 2021 at 2:13 Comment(0)
S
4

Run ---> npx clear-npx-cache

 ----> npx create-react-app your-app
Spaghetti answered 15/12, 2021 at 11:28 Comment(1)
Please remove the ----> that is unnecessary and confusing. – Gavriella
M
3

Run

npx clear-npx-cache

Why?

You already tried to create a react project using create-react-app before.

So there is an old version of create-react-app in the npx cache. /user/.npm/_npx

npm uninstall -g create-react-app won't work for this case.

If you run npx clear-npx-cache it will remove all the caches in the directory /user/.npm/_npx

Now you can create react app using

npx create-react-app my_app
Metchnikoff answered 15/12, 2021 at 17:59 Comment(3)
This works, everyone else that answered below didn't read the OP question. They already tried all of those suggestions. – Gavriella
@Batman thanks for your comment, seems like people don't want to know the reason, but only the solution. – Metchnikoff
removing .npm/_cacache/ did the job for me – Hake
L
1

Try running: npm update

Then run: npx create-react-app my_app

or you can also try with '@latest': npx create-react-app@latest my_app

Lorinalorinda answered 2/6, 2022 at 8:9 Comment(0)
S
0

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/

Yes it appears as is as it is above.

Run some of these two options:

npm uninstall -g create-react-app

OR

yarn global remove create-react-app

Finally try again with npx command create-react-app

In my case, I use the one from npm unistall, finally run the command npx create-react-app again there if I started to create React project.

Shadbush answered 15/12, 2021 at 20:19 Comment(0)
D
0

if you've tried everything above and no success.

Run:

npm audit fix --force

Then:

npx create-react-app <app
Dowden answered 23/12, 2021 at 16:37 Comment(0)
Y
0

If none of the above method worked then follow:

  1. npm i create-react-app@latest_version

    For example : npm i [email protected]

  2. npx create-react-app app_name

    For example : npx [email protected] .

Yarbrough answered 11/6, 2022 at 18:0 Comment(0)
B
0

After trying all above proposed solutions and failing, here is the solution that worked for me:

  1. Navigate to ~/.npm/_npx and ls

  2. You will see a directory similar to this: c67e74de0542c87c/

  3. cd to it

  4. Open package.json and overwrite: { "dependencies": { "create-react-app": "^4.0.3" } } with { "dependencies": { "create-react-app": "^5.0.1" } }

  5. Now you can run npx create-react-app <app-name>

Hopefully this will work for you also.

Bouchard answered 11/8, 2022 at 12:56 Comment(0)
N
0
npx create-react-app@latest app_name

worked for me.

Nucleolus answered 17/9, 2022 at 3:33 Comment(0)
P
-1

I had this same issue and it was happening because I was using nvm to manage node versions and I was running an older node version (12.14.1) for a client project. Using node v14.x.x solved the issue for me.

Procopius answered 19/2, 2022 at 3:11 Comment(0)

© 2022 - 2024 β€” McMap. All rights reserved.