Reputation: 6624
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?
Upvotes: 431
Views: 163359
Reputation: 41
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
Upvotes: 0
Reputation: 21
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!
Upvotes: 0
Reputation: 81
The below steps worked for me
npm uninstall -g create-react-app
npx clear-npx-cache
npm i -g create-react-app
create-react-app myapp
Upvotes: 2
Reputation: 39
if nothing above works ..
use this npx clear-npx-cache
then npx create-react-app my-app
hope it will resolve.
Upvotes: 0
Reputation: 362
npx create-react-app@latest {project name}
this seems to be the way to make it work.
Upvotes: 2
Reputation: 3181
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 > [email protected]: babel-eslint is now @babel/eslint-parser. This package will no longer receive updates.
warning react-scripts > webpack-dev-server > [email protected]: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
warning react-scripts > webpack-dev-server > chokidar > [email protected]: 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/[email protected]: Switch to 'npm install joi'
warning react-scripts > workbox-webpack-plugin > workbox-build > [email protected]: 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:
āāā [email protected] extraneous
I then ran npm uninstall [email protected]
, 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.
Upvotes: 0
Reputation: 496
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.
Upvotes: 1
Reputation: 496
please try this:
npx create-react-app project-name --template all
Upvotes: 0
Reputation: 66
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.
Upvotes: 2
Reputation: 6603
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
Upvotes: 0
Reputation: 288
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:
npm uninstall -g create-react-app
yarn global remove create-react-app
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.npm cache clean --force
npm cache verify
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.
Upvotes: 21
Reputation: 388
For any Windows users still having this issue, this is what fixed it for me:
where create-react-app
to get the path (mine was in C:\Users\username\AppData\Local\Yarn\bin).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.
Upvotes: 2
Reputation: 83
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.
Upvotes: 0
Reputation: 5720
If you've previously installed
create-react-app
globally vianpm install -g create-react-app
, we recommend you uninstall the package usingnpm uninstall -g create-react-app
to ensure thatnpx
always uses the latest version.
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)
Upvotes: 568
Reputation: 51
If you are getting this error 'Template not provided ...." again and again, then straigt away do the followiong to steps:
This will replace your old file 'create-react-app' which is causing the problem with the new file downloaded with npx.
Happy coding...
Upvotes: 0
Reputation: 15898
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
Upvotes: 94
Reputation: 121
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.
Upvotes: 0
Reputation: 11
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
Upvotes: 0
Reputation: 568
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.
Upvotes: 15
Reputation: 888
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
Upvotes: 4
Reputation: 3754
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
Upvotes: 3
Reputation: 104640
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:
Upvotes: 3
Reputation: 1841
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
Upvotes: 0
Reputation: 418
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
Upvotes: 1
Reputation: 1630
npx create-react-app@latest your-project-name
work for me after trying all the answers hope that can help someone in the future.
Upvotes: 14
Reputation: 849
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
Upvotes: 2
Reputation: 681
This worked for me.
npm uninstall -g create-react-app
npx create-react-app my-app
Upvotes: 19
Reputation: 131
All of the option didn't work for me on MacOS. What did work was the following 3 steps:
- Delete the node from: /usr/local/bin/
then
- install node newly: https://nodejs.org/en/
then
- Install react: npx create-react-app my-app follow: https://create-react-app.dev/
Upvotes: 10
Reputation: 2438
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:
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
Upvotes: 22
Reputation: 9787
TLDR: Uninstall the global package using npm uninstall -g create-react-app
and generate new react apps using npx create-react-app app
.
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).
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.
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:
More info about npx can be found in this answer.
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 installsYarn 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.
Upvotes: 7