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?
1)
or
2)
There seems to be a bug where create-react-app isn't properly uninstalled and using one of the new commands lead to:
After uninstalling it with
npm uninstall -g create-react-app
, check whether you still have it "installed" withwhich create-react-app
on your command line. If it returns something (e.g. /usr/local/bin/create-react-app), then do arm -rf /usr/local/bin/create-react-app
to delete manually.3)
Then one of these ways:
TLDR: Uninstall the global package using
npm uninstall -g create-react-app
and generate new react apps usingnpx create-react-app app
.Issue
You're using an older version of
create-react-app
that you have installed globally using npm. Thecreate-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 comparingcreate-react-app --version
withnpm 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 usingnpm update -g create-react-app
. Note that you'll want to do this periodically to keep it up to date. You'll notice thatcreate-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 usenpx
so that it grabs the latest version of the package every time (more detail onnpx
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 asnvm
). 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 thatwhich 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:More info about npx can be found in this answer.
Using
npx
withcreate-react-app
create-react-app
has some special commands/aliases to create a react app (instead ofnpx
) that are specific to that package (yarn create react-app
,npm init react-app
), butnpx create-react-app
will work the same as it does with other packages.yarn
vsnpm
global installsYarn stores global installs in a different folder than
npm
, which is whyyarn 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.
This worked for me 1.First uninstall create-react-app globally by this command:
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:
3.finally:
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.npm install -g create-react-app
in your pcnpx create-react-app my-app
npx create-react-app@latest your-project-name
work for me after trying all the answers hope that can help someone in the future.