21

I am facing a problem with creating a new React app using CRA when I run the following command npx create-react-app my-app.

  • I tried to clear npm cache with this command npm cache clean --force
  • I also tried this command npm -g uninstall create-react-app

My node version is v14.15.3 and the npm version is 7.10.0
The error which I get is :

Need to install the following packages:
  create-react-app
Ok to proceed? (y)
Oussama Bouchikhi
  • 527
  • 1
  • 7
  • 22
  • this is not an error. what did you get after proceeding? – miraj Apr 23 '21 at 17:49
  • create-react-app is not recognized as an internal or external command... – Oussama Bouchikhi Apr 23 '21 at 22:56
  • it seems like a path variable issue. which OS are you using? – miraj Apr 24 '21 at 05:16
  • I am using windows 10 – Oussama Bouchikhi Apr 24 '21 at 16:31
  • could you check `echo %Path%` – miraj Apr 24 '21 at 17:38
  • ```C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Java\jdk1.8.0_271\bin;C:\Program Files\nodejs\;C:\xampp\php;C:\ProgramData\ComposerSetup\bin;;C:\Users\pc cam\AppData\Roaming\npm;...``` – Oussama Bouchikhi Apr 25 '21 at 16:45

10 Answers10

44

Need to clear the cache on the npx:

npx clear-npx-cache

and then re-run

npx create-react-app <app-name>

and then accept (y)

snewn
  • 549
  • 4
  • 4
  • Worked like a charm. Clearing npx cache and re-running cra command worked. – Naveen Venkatesh Dec 24 '21 at 06:01
  • Make sure you're using a current version of Node for this... Our app happens to be using 10.15.3 (barf) so the cache clean wouldn't work and the whole thing wouldn't work. Finally remembered to switch to Node 16+ with nvm, and this solution worked. – Jonathan Tuzman Feb 28 '22 at 21:18
16

Just had the same problem. This worked for me:

  • npm -g uninstall create-react-app
  • npm cache clean --force
  • npm install -g create-react-app
  • npx create-react-app my-app
Antonia Krilić
  • 161
  • 1
  • 3
2

Just clear the cache by running, npx clear-npx-cache and then try to create your react app npx creact-react-app my-app.

1

When it said Ok to proceed? (y) I went through that twice and it told me the version I was using was no longer supported so, npm update

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 19 '21 at 05:35
  • This does not really answer the question. If you have a different question, you can ask it by clicking [Ask Question](https://stackoverflow.com/questions/ask). To get notified when this question gets new answers, you can [follow this question](https://meta.stackexchange.com/q/345661). Once you have enough [reputation](https://stackoverflow.com/help/whats-reputation), you can also [add a bounty](https://stackoverflow.com/help/privileges/set-bounties) to draw more attention to this question. - [From Review](/review/late-answers/30624237) – Andrey Dec 19 '21 at 13:56
1

Hi Oussama Bouchikhi,

You can try the following npm commands to solve the issue:

Run this first,

npm uninstall -g create-react-app

then

npm install -g create-react-app

Here's the snapshot of the same, create-react-app-issue

Let us know if it works! Happy Hacking!

1
  1. Options 1
    Switch to yarn instead of npm
    npm i -g yarn
    yarn create react-app
    
  2. Options 2
    Uninstal Node completely and re-instal it again
  3. Option 3
    Use nvm (Node Version Manager)
Oussama Bouchikhi
  • 527
  • 1
  • 7
  • 22
0

When it gives you this error, it asks your permission to install create-react-app

...
Ok to proceed? (y)

Type y in your terminal and press enter

You might find this helpful as well: https://create-react-app.dev/docs/getting-started/

If you've previously installed create-react-app globally via npm install -g create-react-app, we recommend you 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.

GonEbal
  • 228
  • 2
  • 8
0

could you try to add this path to your system variable? C:\Users\<user-name>\AppData\Roaming\npm

and try again with npx create-react-app <app-name>

miraj
  • 546
  • 3
  • 12
0

You need to clear your npx cache first.

Delete the folder _npx inside the path returned by npm config get cache

# In Linux/MacOS terminal
rm -rf `npm config get cache`/_npx

This can also be done with @snewn's method, I posted this in case you want to skip that dependency.

David Villamizar
  • 802
  • 9
  • 16
0

Need to clear the cache on the npx:

npx clear-npx-cache and then re-run

npx create-react-app and then accept (y)

Subxmi
  • 9
  • 2
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 26 '21 at 08:39
  • 1
    This is the same as the top-voted answer, but without formatted code blocks. – Tom Dixon Mar 19 '22 at 20:57