当我在我的终端上输入create-react-app my-app命令时,它似乎工作了-下载所有库成功等。在该过程结束时,我得到一个消息,没有提供模板。

输入

user@users-MacBook-Pro-2 Desktop% create-react-app my-app

输出

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.

在包中。my-app的Json:

"dependencies": {
  "react": "^16.12.0",
  "react-dom": "^16.12.0",
  "react-scripts": "3.3.0" <-- up-to-date
}

我检查了CRA更改日志,它看起来像是增加了对自定义模板的支持-但是它看起来不像命令create-react-app my-app会改变。

知道这是怎么回事吗?


当前回答

在你的电脑上安装-g create-react-app 用NPX Create -react-app my-app再次创建react项目

其他回答

第一次全局卸载create-react-app:

npm uninstall -g create-react-app

然后在你的项目目录中:

npm install create-react-app@latest

最后:

npx create-react-app my-app

这对我很管用。

NPM卸载-g create-react-app create-react-app my-app

在你的电脑上安装-g create-react-app 用NPX Create -react-app my-app再次创建react项目

这个问题不是这样解决的,问题是在node的不同实例中,尝试全局删除create-react-app,然后删除node_modules和package-lock。来自根用户的Json

如果以上都不行… 使用NPX clear-npx-cache 然后NPX create-react-app my-app 希望它能解决。