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

1

13 Answers 13

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
5
  • 7
    Thank you! I tried everything from clearing npm cache to uninstalling and reinstalling node, finally this solution fixed it :)
    – SamiElk
    Dec 15, 2021 at 17:39
  • 4
    Thanks! that command fixed my issue. Dec 15, 2021 at 22:57
  • 3
    this does works! please tick this answer
    – Alan Yong
    Dec 28, 2021 at 7:28
  • I am running into stuck after running npx clear-npx-cache with node v14.16.0 and npm 6.14.11 on Windows 10
    – liuliang
    Dec 30, 2021 at 8:51
  • still working with npm 8.11.0 and node v16.15.1 ! Thank you !
    – Alan Hortz
    Oct 12, 2022 at 10:05
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 .
3
  • 2
    Clearing the npx cache did the trick for me. I'm in happy hacking territory again, much appreciated!!! Dec 14, 2021 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 Dec 15, 2021 at 1:28
  • You could try yarn create react-app@latest
    – Sators
    Dec 16, 2021 at 4: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

3
  • 2
    Thanks @sanad-khamash. npx create-react-app@latest worked for me to ensure that I am running create-react-app latest version.
    – Shraddha
    Dec 15, 2021 at 22:43
  • 1
    @Shraddha You're more than welcome sir. Dec 15, 2021 at 23:34
  • npx create-react-app@latest Your_project_name worked for me Dec 19, 2022 at 12:52
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
1
  • Please remove the ----> that is unnecessary and confusing.
    – CWSites
    Apr 16, 2022 at 20:28
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
3
  • 1
    This works, everyone else that answered below didn't read the OP question. They already tried all of those suggestions.
    – CWSites
    Apr 16, 2022 at 20:27
  • @Batman thanks for your comment, seems like people don't want to know the reason, but only the solution.
    – Honey
    Feb 21 at 19:06
  • removing .npm/_cacache/ did the job for me
    – Roshan
    Apr 10 at 7:56
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

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.

0

if you've tried everything above and no success.

Run:

npm audit fix --force

Then:

npx create-react-app <app
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] .

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.

-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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.