【发布时间】:2020-03-29 23:59:50
【问题描述】:
当我在终端中键入 create-react-app my-app 命令时,它似乎可以工作 - 成功下载所有库等。但在该过程结束时,我收到一条消息,指出 template was not provided。
输入
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的package.json中:
"dependencies": {
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-scripts": "3.3.0" <-- up-to-date
}
我检查了 CRA changelog,它看起来像是添加了对自定义模板的支持 - 但是它看起来不像命令 create-react-app my-app 会改变。
知道这里发生了什么吗?
【问题讨论】:
-
传闻全球包已经不那么火了。尝试'npm init react-app my-app'
-
同时更新您的安装
-
谢谢 - 最终工作(使用 Yarn)正在升级 CRA:
yarn global upgrade create-react-app- 然后做yarn create react-app my-app -
我在 Windows 机器上遇到了同样的问题
-
这里也一样,在 Windows 上
npm uninstall -g create-react-app没有解决它。我必须去文件夹C:\Users\serge\AppData\Roaming\npm(你的路径会有所不同),并在这个文件夹中执行npm uninstall creat-react-app。之后我安装了npx create-react-app sample-react --template typescript --use-npm。