425

When I type the create-react-app my-app command in my terminal, it appears to work - downloading all libraries successfully etc. At the end of that process however I get a message that a template was not provided.

Input

user@users-MacBook-Pro-2 Desktop% create-react-app my-app

Output

Creating a new React app in /Users/user/Desktop/my-app.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...
..... nothing out of the ordinary here .....
✨  Done in 27.28s.

A template was not provided. This is likely because you're using an outdated version of create-react-app.
Please note that global installs of create-react-app are no longer supported.

In package.json of my-app:

"dependencies": {
  "react": "^16.12.0",
  "react-dom": "^16.12.0",
  "react-scripts": "3.3.0" <-- up-to-date
}

I checked out the CRA changelog and it looks like support was added for custom templates - however it doesn't look like the command create-react-app my-app would have changed.

Any idea what is going on here?

SamYoungNY
  • 6,444
  • 6
  • 26
  • 43
  • 11
    rumor is that the global package isn't so hot anymore. try 'npm init react-app my-app' – Tim Wilson Dec 05 '19 at 05:28
  • 13
    Also update your install – Tim Wilson Dec 05 '19 at 05:32
  • 14
    Thanks - what ended up working (using Yarn) is upgrading CRA with: `yarn global upgrade create-react-app` - then doing `yarn create react-app my-app` – SamYoungNY Dec 05 '19 at 06:02
  • I got the same problem on a windows machine – Max Carroll Feb 27 '20 at 21:05
  • 1
    what worked for me when all the advice here failed was doing `locate create-react-app` and deleting all directories that had `create-react-app` in the name. Only then did `npx create-react-app` finally work normally again for me. – Kai Carver Mar 23 '20 at 09:53
  • 2
    Same here, on Windows `npm uninstall -g create-react-app` did not solve it. I had to go to the folder `C:\Users\serge\AppData\Roaming\npm` (your path will vary), and execute `npm uninstall creat-react-app` in this folder. After that I installed with `npx create-react-app sample-react --template typescript --use-npm`. – Serge van den Oever Jul 14 '20 at 08:29
  • just check the following link. It should help you https://create-react-app.dev/docs/updating-to-new-releases/ – Pavan Sep 10 '20 at 13:58
  • @Serge van den Oever you have solved my problem. – edinvnode Sep 15 '21 at 22:03

44 Answers44

564

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 to ensure that npx always uses the latest version.

Docs

Use either one of the below commands:

  • npx create-react-app my-app
  • npm init react-app my-app
  • yarn create react-app my-app

if npm uninstall -g create-react-app stated above does not work. Type which create-react-app to know where it is installed. Mine was installed in /usr/bin folder. Then do sudo rm -rf /usr/bin/create-react-app. (Credit to @v42 comment below)

dabo248
  • 3,367
  • 4
  • 27
  • 37
Latha Eshappa
  • 5,680
  • 1
  • 5
  • 2
  • 24
    I thought npm uninstall -g create-react-app and npx create-react-app my-app would work. But somehow npx still creates a project without the template. Is create-react-app somehow cached? I thought having a global cra installation would be deprecated. I had to update create-react-app -g instead before using npx. – Robin Wieruch Dec 05 '19 at 06:56
  • 163
    if you still have the same error after `npm uninstall -g create-react-app`, enter `which create-react-app` in your console. If it returns something like `/usr/local/bin/create-react-app`, then do a `rm -rf /usr/local/bin/create-react-app` to delete manually. – v42 Dec 05 '19 at 15:13
  • 14
    This is not a good approach IMHO. why do we have to be downloading and running stuff each time instead of having a local copy? Its waste of bandwidth and a very good way to execute random code from the internet and one day get hacked.... Just reinstall it like I did `npm install create-react-app -g` my solution means you will eventually get this error again but people *should not* be running arbitrary code from the webs and should be able to stay on a specific version if they choose so.... – Rodrigo Graça Dec 07 '19 at 10:30
  • 9
    finally got it to work for typescript template `npm uninstall -g create-react-app` `sudo rm -rf /usr/local/bin/create-react-app` `npx create-react-app newapp --template typescript` – CyberProdigy Dec 09 '19 at 21:23
  • 2
    use this `npm list -g --depth=0` to see whether create-react-app is listed in your installed node packages. If it is, run `npm uninstall -g create-react-app` to uninstall. – Chris Claude Dec 15 '19 at 18:09
  • 1
    @v42 i still have same proplems I tried uninstalling global create react app and then deleted from the local manually . still I am getting the same error. – Faiz Hameed Jan 08 '20 at 06:46
  • 7
    If these solutions don't work for you, it may be possible that you installed the package globally via `yarn` like I evidently did. In that case use `yarn global remove create-react-app` to remove it. – abettermap Jan 08 '20 at 19:24
  • for every one on windows using `npx` to make a react app like `npx create-react-app my-app` I tried everything. Literally everything, but when I accidentally forgot to type `npx` it worked. I just typed `create-react-app my-app` and it gave me a template with no known errors! – TheIvoryCoder Dec 18 '21 at 22:46
  • On my MacOS 12.4, I searched in the Finder for "create-react-app" and found the react folder, and deleted everything. That seems to have worked. – grigb May 29 '22 at 20:08
94

1)

npm uninstall -g create-react-app

or

yarn global remove create-react-app

2)

There seems to be a bug where create-react-app isn't properly uninstalled and using one of the new commands lead to:

A template was not provided. This is likely because you're using an outdated version of create-react-app.

After uninstalling it with npm uninstall -g create-react-app, check whether you still have it "installed" with which create-react-app (Windows: where create-react-app) on your command line. If it returns something (e.g. /usr/local/bin/create-react-app), then do a rm -rf /usr/local/bin/create-react-app to delete manually.

3)

Then one of these ways:

npx create-react-app my-app
npm init react-app my-app
yarn create react-app my-app
Robin Wieruch
  • 14,900
  • 10
  • 82
  • 107
  • 5
    I had to remove the installation folder, npm uninstall create-react-app -g did not work – artfulbeest Dec 10 '19 at 08:08
  • 2
    $ echo '#!/bin/sh' > /usr/local/bin/create-react-app $ echo 'echo use yarn create-react-app instead' > /usr/local/bin/create-react-app $ chmod 0700 /usr/local/bin/create-react-app – Jason FB Dec 11 '19 at 15:52
  • 3
    On Windows, you can use the command `where` instead of `which` – mgiurni Jan 23 '20 at 23:16
56

Though already lots of answer is here. I came up with 3 solutions which I applied step by step when I faced this situation.


First step: From Official manual,

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 to ensure that npx always uses the latest version.

https://create-react-app.dev/docs/getting-started

You can use these commands below:

  • npx create-react-app my-app
  • npm init react-app my-app
  • yarn create react-app my-app

Second step (If first one doesn't work):

Sometimes it may keep caches.then you can use these commands given below.

  • npm uninstall -g create-react-app
  • npm cache clean --force
  • npm cache verify
  • yarn create react-app my-app

Third step:(If these 2 won't work) first uninstall via npm uninstall -g create-react-app,then check if you still have it "installed" with which create-react-app command on your command line. If you got something like (/usr/local/bin/create-react-app) then run this rm -rf /usr/local/bin/create-react-app (folder may vary) to delete manually. Then again install it via npx/npm/yarn.

NB: I succeed in the last step.

Kristianmitk
  • 4,528
  • 5
  • 26
  • 46
Moshiur Rahman
  • 1,534
  • 12
  • 26
  • For whatever reason, `npx` and `npm init` did not work, but `yarn` did after clearing cache. I needed to `rm -rf` the `create-react-app` folder too. So thankful for SO. – ZebGir Mar 05 '20 at 03:56
  • on windows (from a wsl terminal) `which create-react-app` showed that I needed to delete the `create-react-app*` files in `/mnt/c/Users/myWindowsUser/AppData/Roaming/npm/` – cyrf Dec 07 '20 at 00:49
45

First uninstall create-react-app globally by this command:

npm uninstall -g create-react-app

then in your project directory:

npm install create-react-app@latest

finally:

npx create-react-app my-app
S.S. Anne
  • 15,171
  • 8
  • 38
  • 76
Tooba Anwar
  • 469
  • 3
  • 4
22

To add up more to the answers above:

With the new release of create-react-app, you can create a new app using custom templates. Two templates available so far:

  • cra-template
  • cra-template-typescript

Usage:

npx create-react-app my-app [--template typescript]

More details of the latest changes in create-react-app:

https://github.com/facebook/create-react-app/releases/tag/v3.3.0

Bakhtiiar Muzakparov
  • 2,308
  • 2
  • 15
  • 24
21

Clear your npm cache first then use yarn as follows:

  • npm cache clean --force
  • npm cache verify
  • yarn create react-app my-app

I hope this helps.

EDIT

...you might want to try the following after I have looked into this problem further:

  1. npm uninstall -g create-react-app
  2. yarn global remove create-react-app
  3. which create-react-app - If it returns something (e.g. /usr/local/bin/create-react-app), then do a rm -rf /usr/local/bin/create-react-app to delete manually.
  4. npm cache clean --force
  5. npm cache verify
  6. npx create-react-app@latest

These steps should remove globally installed create-react-app installs, you then manually remove the old directories linked to the old globally installed create-react-app scripts. It's then a good idea to clear your npm cache to ensure your not using any old cached versions of create-react-app. Lastly create a new reactjs app with the @latest option like so: npx create-react-app@latest. There has been much confusion on this issue where no template is created when using npx create-react-app, if you follow the steps I have stated above (1-6) then I hope you'll have success.

p.s.

If I wanted to then create a react app in a directory called client then I would type the following command into the terminal:

npx create-react-app@latest ./client

Good luck.

DevStormUK
  • 278
  • 1
  • 9
20

I too had the same problem. When I trid the npm init react-app my-app command returned the same message

A template was not provided. This is likely because you're using an outdated version of create-react-app.

But

yarn create react-app my-app command works fine.

S.S. Anne
  • 15,171
  • 8
  • 38
  • 76
Gopalakrishnan T
  • 453
  • 1
  • 4
  • 14
19
  1. npm install -g create-react-app in your pc
  2. create react project again with npx create-react-app my-app
S.S. Anne
  • 15,171
  • 8
  • 38
  • 76
akbaral aziz
  • 231
  • 1
  • 2
19

This worked for me.

  1. npm uninstall -g create-react-app
  2. npx create-react-app my-app
0x90
  • 39,472
  • 36
  • 165
  • 245
akhildhiman
  • 642
  • 9
  • 23
15

So I've gone through all the steps here, but non helped.

TLDR; run npx --ignore-existing create-react-app

I am on a Mac with Mojave 10.15.2

CRA was not installed globally - didn't find it in /usr/local/lib/node_modules or /usr/local/bin either.

Then I came across this comment on CRA's github issues. Running the command with the --ignore-existing flag helped.

Ben S
  • 558
  • 3
  • 18
  • "npx: the --ignore-existing argument has been removed." but still, none of the answers so far fixed the issue. – iair Oct 26 '21 at 02:20
  • I sold my mac and did a fresh install on the new one... sounds bizarre... – Ben S Oct 27 '21 at 07:31
13

npx create-react-app@latest your-project-name

work for me after trying all the answers hope that can help someone in the future.

Buk Lau
  • 1,540
  • 3
  • 11
  • 18
12

These two steps worked for me

1) Uninstalled react-app globally with this command

npm uninstall -g create-react-app

2) Installed react-app in project folder with this command

npx create-react-app project-name
Hammad Hassan
  • 606
  • 7
  • 20
10

"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 to ensure that npx always uses the latest version"

This is reported at https://create-react-app.dev/docs/getting-started/. For me, this did not work. I had to re-install create-react-app globally instead.

My steps to fix this problem were to:

  1. npm uninstall -g create-react-app
  2. npm install -g create-react-app
  3. npx create-react-app my-app
Gully Habibi
  • 117
  • 3
  • 1
    It's not recommended to use a global installation of create-react-app anymore. – Robin Wieruch Dec 06 '19 at 06:45
  • 4
    This is true, however, I couldn't figure out another way to install the template without doing a global installation. It doesn't make a difference to my app anyway. – Gully Habibi Dec 07 '19 at 07:25
10

All of the option didn't work for me on MacOS. What did work was the following 3 steps:

  1. Delete the node from: /usr/local/bin/

then

  1. install node newly: https://nodejs.org/en/

then

  1. Install react: npx create-react-app my-app follow: https://create-react-app.dev/
N'Bayramberdiyev
  • 5,936
  • 7
  • 27
  • 47
nroy
  • 131
  • 6
  • Yes that is correct - then check to see if it is still installed $ react-create-app --version. IF there is still a version you may have to remove it manually. In my case it remained ~/.nvm/versions/node//lib/node_modules so you have to rm -rf react-create-app in that folder – Michael Nelles Dec 21 '19 at 19:06
7

For Linux this worked for me

sudo npm uninstall -g create-react-app
npx create-react-app my-test-app
coding_Lover
  • 393
  • 1
  • 4
  • 13
7

TLDR: Uninstall the global package using npm uninstall -g create-react-app and generate new react apps using npx create-react-app app.


Issue

You're using an older version of create-react-app that you have installed globally using npm. The create-react-app command invokes this global package.

You could've confirmed that you were using an outdated version by running npm outdated -g create-react-app or comparing create-react-app --version with npm view create-react-app.

The fact that the version of react-scripts was up to date, has nothing to do with the version of the package that is bootstrapping the app (create-react-app), which grabs the latest versions of the packages that it uses (react-scripts in this case).

Solution

If you want to continue using the create-react-app command, you'll need to update the global package using npm update -g create-react-app. Note that you'll want to do this periodically to keep it up to date. You'll notice that create-react-app does not recommend this (noted in the logs from your install).

A better approach would be to delete the global install entirely (npm uninstall -g create-react-app) and instead use npx so that it grabs the latest version of the package every time (more detail on npx below).

You should confirm that it was uninstalled globally by trying to use create-react-app to make sure the command is "not found".

Issues with uninstalling?

You can debug where it was installed using which create-react-app. If you're having issues uninstalling it, you may have multiple versions of node/npm on your machine (from multiple installs, or because you use a node version manager such as nvm). This is a separate issue I won't address here, but there's some info in this answer.

A quick nuclear approach would be to forcefully remove it (rm -rf) at the path that which create-react-app returns.


Supplement

Global npm packages and the npx command

$ NPM_PACKAGE_NAME will always use the globally installed version of the package, regardless of which directory you're in.

$ npx NPM_PACKAGE_NAME will use the first version of the package that it finds when searching up from the current directory to the root:

  • If you have the package in your current directory, it will use that.
  • Else if you have the package in a directory that is a parent of your current directory, it will use the first one it finds.
  • Else if you have the package installed globally, it will use that.
  • Else if you don't have the package at all, it will temporarily install it, use it, and then discard it. - this is the best way to ensure the package is up to date.

More info about npx can be found in this answer.

Using npx with create-react-app

create-react-app has some special commands/aliases to create a react app (instead of npx) that are specific to that package (yarn create react-app, npm init react-app), but npx create-react-app will work the same as it does with other packages.

yarn vs npm global installs

Yarn stores global installs in a different folder than npm, which is why yarn create react-app would work immediately without uninstalling the global npm package (as far as yarn is concerned, the package hasn't been installed).

This is just a temporary solution though, as you'll need to remember to always use yarn instead of npm when using Create React App.

JBallin
  • 8,481
  • 4
  • 46
  • 51
6

This works for me!

1) npm uninstall -g create-react-app

2) npm install -g create-react-app

3) npx create-react-app app_name

If you have any previously installed create-react-app globally via npm install -g create-react-app, Better to uninstall it using npm uninstall -g create-react-app

5

This solved my problem

Steps:

1.Uninstall the create-react app

npm uninstall -g create-react-app

2.Now just use

npx create-react-app my-app

this will automatically create the template for u .

RamPrakash
  • 1,687
  • 3
  • 20
  • 25
ari sudhan
  • 69
  • 3
5

This problem is not solved like this, the problem is in the different instances of node, try removing globally create-react-app and then delete the node_modules and package-lock.json from your root user

Luis Meneses
  • 109
  • 7
4

This work's for me :

Let's, uninstall create-react-app globally by this command:

npm uninstall -g create-react-app

After that in your project directory:

npm install create-react-app@latest

At the last:

npx create-react-app my-app

For typescript :

npx create-react-app my-app --template typescript
shivlal kumavat
  • 868
  • 1
  • 12
  • 28
3

First uninstall create-react-app

npm uninstall -g create-react-app

Then run yarn create react-app my-app or npx create-react-app my-app

then running yarn create react-app my-app or npx create-react-app my-app may still gives the error,

A template was not provided. This is likely because you're using an outdated version of create-react-app.Please note that global installs of create-react-app are no longer supported.

This may happens because of the cashes. So next run

npm cache clean --force 

then run

npm cache verify

Now its all clear. Now run

yarn create react-app my-app or npx create-react-app my-app

Now you will get what you expected!

3

I fix this issue on Mac by uninstalling create-react-app from global npm lib, that's basically what said, just try to do, you need also do sudo:

sudo npm uninstall -g create-react-app

Then simply run:

npx create-react-app my-app-name

Now should be all good and get the folder structures as below:

template not provided using create react app

Alireza
  • 100,211
  • 27
  • 269
  • 172
  • 1
    I was trying all these writed above methods on Linux Mint 19 (Ubuntu based system). Nothing helped, but this did it. `sudo npm uninstall -g create-react-app` – northernwind Feb 29 '20 at 20:08
3

Using the command npm uninstall -g create-react-app didn't work for me.

But this worked:

yarn global remove create-react-app

and then:

npx create-react-app my-app

Karthic Rao
  • 3,624
  • 8
  • 30
  • 44
2

Such a weird problem because this worked for me yesterday and I came across the same error this morning. Based on the release notes, a new feature was added to support templates so it looks like a few parts have changed in the command line (for example, the --typescript was deprecated in favor of using --template typescript)

I did manage to get it all working by doing the following:

  1. Uninstall global create-react-app npm uninstall create-react-app -g.
  2. Verify npm cache npm cache verify.
  3. Close terminal. I use the mac terminal, if using an IDE maybe close and re-open.
  4. Re-open terminal, browse to where you want your project and run create-react-app via npx using the new template command conventions. For getting it to work, I used the typescript my-app from the documentation site to ensure consistency: npx create-react-app my-app --template typescript

If it works, you should see multiple installs: one for react-scripts and one for the template. The error message should also no longer appear.

Ryan McCormick
  • 104
  • 1
  • 5
2

npm uninstall -g create-react-app could be an answer in some cases, but not in mine.

You should manually delete your create-react-app located at ~/.node/bin/ or /usr/bin/ (just type which create-react-app and remove it from locations you saw using rm -rf), next just run npm i -g create-react-app.

After that create-react-app will be working correctly.

Andrew
  • 107
  • 2
  • 12
2

This worked for me 1.First uninstall create-react-app globally by this command:

npm uninstall -g create-react-app

If there you still have the previous installation please delete the folder called my app completely.(Make sure no program is using that folder including your terminal or cmd promt)

2.then in your project directory:

npm install create-react-app@latest

3.finally:

npx create-react-app my-app
2

For any Windows users still having this issue, this is what fixed it for me:

  1. Run where create-react-app to get the path (mine was in C:\Users\username\AppData\Local\Yarn\bin).
  2. Navigate to that directory and delete both "create-react-app" and "create-react-app.cmd".
  3. Navigate to the directory you want to start a project in.
  4. Run npm install create-react-app, npx create-react-app name-of-app, cd name-of-app, yarn start.

Step #4 will vary based on your configuration, but that's just what got me up and running.

Alex Ertl
  • 358
  • 3
  • 7
  • 1
    Can confirm. Deleting just the "create-react-app" doesn't fix it, but deleting both that and "create-react-app.cmd" did. – GonnaGetGet Jul 08 '20 at 04:48
2

One of the easiest way to do it is by using

npx --ignore-existing create-react-app [project name]

This will remove the old cached version of create-react-app and then get the new version to create the project.

Note: Adding the name of the project is important as just ignoring the existing create-react-app version is stale and the changes in your machines global env is temporary and hence later just using npx create-react-app [project name] will not provide the desired result.

2
npx create-react-app@latest {project name}

this seems to be the way to make it work.

Lindsey
  • 172
  • 1
  • 7
2

The below steps worked for me

  1. npm uninstall -g create-react-app

  2. npx clear-npx-cache

  3. npm i -g create-react-app

  4. create-react-app myapp

Adriaan
  • 17,741
  • 7
  • 42
  • 75
Arijit das
  • 69
  • 8
1

After using this command:

yarn global upgrade create-react-app

I then tried:

yarn create-react-app my-app but it didn't work for me.

This worked though:

npx create-react-app my-app 
Helen_CEE
  • 39
  • 3
1

For Windows 10 I had to manually delete some folders in yarn's cache, my path was something like C:\Users\username\AppData\Local\Yarn\Cache\v1 and the foldes I had to remove were something like npm-create-react-app-1.0.0-1234567890abcdef

dadiaar
  • 418
  • 5
  • 13
  • For Windows 7 this also solved my issue. One I deleted the Yarn cache and ran `npm cache clear --force`, etc I was able to run `npx create react app`. – Kentaro Sep 18 '20 at 04:45
1

I solved this using the following command.

npm uninstall -g create-react-app

npm cache clean --force

then

npx create-react-app project_name --template all

Thanks for this! Worked for me too.

Chaurasia
  • 494
  • 1
  • 6
  • 22
  • Still got some error "A template was not provided. This is likely because you're using an outdated version of create-react-app" even after those step. Wonder, shouldn't be Typescript the "template"? – Carmine Tambascia Sep 10 '21 at 08:51
0

I had same problem & i have installed "create-react-app" globally on my machine. There is error :

"A template was not provided. This is likely because you're using an outdated version of create-react-app. Please note that global installs of create-react-app are no longer supported."

Then i removed previous install by using this command.

npm uninstall -g create-react-app

Then install new react app.

npx create-react-app new-app

akshay_sushir
  • 1,483
  • 11
  • 9
0

Try running your terminal as an administrator. I was having the same issue and nothing helped apart from opening the terminal as administrator and then doing the npx create-react-app yourAppName

0

FOR UBUNTU: in case you are having an error that a template is not provided with npx create-react-app and already unistalled npm create-react-app -g and still doesn't work, do the following:

sudo rm -rf usr/bin/create-react-app    

# this will manualy remove the create-react-app. 
npx create-react-app 

either with typescript works too.

biruk1230
  • 3,042
  • 4
  • 16
  • 29
Halil
  • 121
  • 7
0

If you are getting this error 'Template not provided ...." again and again, then straigt away do the followiong to steps:

  1. npm uninstall -g create-react-app
  2. check the location of your file 'create-react-app' by using the command "which create-react-app"
  3. Now manually delete that file using the command "rm -rf /usr/local/bin/create-react-app" replacing this command with the exact path shown in the previous step.
  4. Finally run 'npx create-react-app '

This will replace your old file 'create-react-app' which is causing the problem with the new file downloaded with npx.

Happy coding...

Raj
  • 51
  • 1
  • 5
0

I got the same problem in last week. I tried many things that is provided in this answer section. But now this thing is different. Latest version of this create-react-app provided 2 templates.

1. cra-template

2. cra-template-typescript

If you use javascript, choose cra-template. And if you use typescript, use cra-template-typescript.

First you have to uninstall the create-react-app. (If you have the latest version, ignore this step.)

 npm uninstall -g create-react-app

Again install the latest version of the create-react-app

npm install create-react-app@latest

Now you have to import the template like this. (If you use typescript, use "cra-template-typescript" instead of "cra-template". my-app is used as a name. you can give it any name).

npx create-react-app my-app --template cra-template

Now the template will be downloaded. But remind in your mind, this is not equal to the past versions. (something different)

Happy Coding.

Alessio
  • 3,404
  • 19
  • 35
  • 48
Jonny
  • 73
  • 8
0

This problem occurred because there is global installs of create-react-app are no longer supported. For solving this problem, you should uninstall and remove completely create-react-app from your system, so run these command respectively:

npm uninstall -g create-react-app

or

yarn global remove create-react-app

Then please check if the create-react-app exists or not with this command

which create-react-app

If it returns any correct path like a

/c/Users/Dell/AppData/Local/Yarn/bin/create-react-app

Then run this command to remove create-react-app globally

rm -rf /c/Users/Dell/AppData/Local/Yarn/bin/create-react-app

Now you can create a new react app with one of these commands:

npx create-react-app my-app
npm init react-app my-app
yarn create react-app my-app
S. Hesam
  • 5,266
  • 3
  • 37
  • 59
0

please try this:

npx create-react-app project-name --template all

Chaurasia
  • 494
  • 1
  • 6
  • 22
0

If other answers are not helping and especially if you recently moved to Big Sur, this may be helpful.

I tried all of the steps described in all answers, but could not get CRA to generate a template for me. It may have been due to the fact that I recently moved to Big Sur, and had not updated node/npm etc. The create-react-app binary was not installed (neither in /usr/bin nor in /usr/local/bin), but anytime I would run npx create-react-app project it would end with the dreaded "A template was not provided.." message. I upgraded node and npm, tried removing create-react-app using both npm and yarn, cleared the npm cache, tried using npm react-app project, all to no avail.

Whenever I would run these commands, it would start with complaining about react-scripts using outdated packages:

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...

yarn add v1.22.10
info No lockfile found.
[1/4]   Resolving packages...
warning react-scripts > babel-eslint@10.1.0: babel-eslint is now @babel/eslint-parser. This package will no longer receive updates.
warning react-scripts > webpack-dev-server > chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
warning react-scripts > webpack-dev-server > chokidar > fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
warning react-scripts > workbox-webpack-plugin > workbox-build > @hapi/joi@15.1.1: Switch to 'npm install joi'
warning react-scripts > workbox-webpack-plugin > workbox-build > rollup-plugin-babel@4.4.0: This package has been deprecated and is no longer maintain
<etc. - tons of warnings like these>

So I suspected that maybe react-scripts was the problem. To check, I ran npm list. To my surprise, CRA was listed as one of the "extraneous" packages:

├── create-react-app@1.5.2 extraneous

I then ran npm uninstall create-react-app@1.5.2, which worked. And the next invocation of npx create-react-app project prompted me that CRA would be installed. Sure enough, the installation worked and a template was indeed used.

Hope this helps anyone stuck in similar situation.

LNI
  • 2,935
  • 2
  • 21
  • 25
0

if nothing above works .. use this npx clear-npx-cache then npx create-react-app my-app hope it will resolve.

0

If nothing of the above worked for you this is what I did: On ubuntu (and probably mac and windows) search for the node_modules folder and manualy delete the create-react-app module, update the package.json and package-lock.json and run again

npx create-react-app <app-name>

works!

0

No one mentioned the most basic problem but, Windows users. Make sure you update your node version. None of the answers worked for me until I updated my node.js

Glitch Fish
  • 41
  • 1
  • 13
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/33570352) – Eyeslandic Jan 06 '23 at 22:08