Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Template not provided using create-react-app

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?

like image 682
SamYoungNY Avatar asked Dec 05 '19 05:12

SamYoungNY


People also ask

Why NPX create React app not working?

We no longer support global installation of Create React App. The current solution is simple — run create-react-app and target the latest version. Different versions of npm may help as well, and you can upgrade using the following command. Please note that this may affect other projects on your system.

Is create React app still supported?

Create-react-app no longer supported #12314 Please note that global installs of create-react-app are no longer supported. You can fix this by running npm uninstall -g create-react-app before using create-react-app again.

Where can I find free React templates?

Treact. Treact is a gallery of free and modern React templates and UI components developed using TailwindCSS as the front-end framework. This archive of beautiful resources provides 7 pre-built main pages, 8 secondary pages, and 52 pre-designed elements and sections.


2 Answers

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)

like image 182
Latha Eshappa Avatar answered Sep 24 '22 00:09

Latha Eshappa


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 
like image 35
Robin Wieruch Avatar answered Sep 24 '22 00:09

Robin Wieruch