48

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

Forrest Naylor
  • 483
  • 2
  • 6

10 Answers10

83

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

DEEPTHI MUKUNDAN
  • 840
  • 1
  • 1
  • 5
28

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 .
Sators
  • 1,655
  • 15
  • 20
  • 1
    Clearing the npx cache did the trick for me. I'm in happy hacking territory again, much appreciated!!! – Forrest Naylor Dec 14 '21 at 17:00
  • 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 – Manuel Pirez Dec 15 '21 at 01:28
  • You could try `yarn create react-app@latest` – Sators Dec 16 '21 at 04:01
11

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

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.

4

Run ---> npx clear-npx-cache

 ----> npx create-react-app your-app
2

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

gmj
  • 1,855
  • 9
  • 19
  • This works, everyone else that answered below didn't read the OP question. They already tried all of those suggestions. – Crypto Batman Apr 16 '22 at 20:27
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.

Ravi Kumar Gupta
  • 1,574
  • 2
  • 19
  • 36
0

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

MacGregor
  • 21
  • 4
-1

if you've tried everything above and no success.

Run:

npm audit fix --force

Then:

npx create-react-app <app
svelandiag
  • 4,201
  • 1
  • 33
  • 66
-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.

CaseyC
  • 1,299
  • 13
  • 22