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条回答
我只想做你的唯一
2楼-- · 2020-02-07 14:25

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.

查看更多
倾城 Initia
3楼-- · 2020-02-07 14:26

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.

查看更多
唯我独甜
4楼-- · 2020-02-07 14:26

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 
查看更多
The star\"
5楼-- · 2020-02-07 14:27

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

查看更多
Evening l夕情丶
6楼-- · 2020-02-07 14:28

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
查看更多
beautiful°
7楼-- · 2020-02-07 14:28

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

查看更多
登录 后发表回答