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

Forrest Naylor
  • 513
  • 1
  • 3
  • 6
  • Does this answer your question? [Error while creating new React app ("You are running \`create-react-app\` 4.0.3, which is behind the latest release (5.0.0)")](https://stackoverflow.com/questions/70358474/error-while-creating-new-react-app-you-are-running-create-react-app-4-0-3-w) – Henke Mar 29 '23 at 12:31

13 Answers13

101

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
Pete
  • 12,206
  • 8
  • 54
  • 70
DEEPTHI MUKUNDAN
  • 1,140
  • 2
  • 2
  • 5
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 .
Sators
  • 2,746
  • 1
  • 20
  • 26
  • 2
    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
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

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
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
Honey
  • 2,208
  • 11
  • 21
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

MacGregor
  • 51
  • 4
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,698
  • 2
  • 22
  • 38
0

if you've tried everything above and no success.

Run:

npm audit fix --force

Then:

npx create-react-app <app
svelandiag
  • 4,231
  • 1
  • 36
  • 72
0

If none of the above method worked then follow:

  1. npm i create-react-app@latest_version

    For example : npm i create-react-app@5.0.1

  2. npx create-react-app app_name

    For example : npx create-react-app@5.0.1 .

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.

0
npx create-react-app@latest app_name

worked for me.

Ahmet Emre Kilinc
  • 5,489
  • 12
  • 30
  • 42
-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,453
  • 14
  • 23