Template not provided using create-react-app

2020-02-07 14:16发布

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?

29条回答
\"骚年 ilove
2楼-- · 2020-02-07 14:31

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
查看更多
倾城 Initia
3楼-- · 2020-02-07 14:33

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

查看更多
霸刀☆藐视天下
4楼-- · 2020-02-07 14:35

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

查看更多
爷的心禁止访问
5楼-- · 2020-02-07 14:36

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/
查看更多
Viruses.
6楼-- · 2020-02-07 14:36

For Linux this worked for me

sudo npm uninstall -g create-react-app
npx create-react-app my-test-app
查看更多
家丑人穷心不美
7楼-- · 2020-02-07 14:38

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 .

查看更多
登录 后发表回答