当我在终端中键入 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 更改日志,似乎添加了对自定义模板的支持 - 但它看起来不像命令 create-react-app my-app
会改变。
知道这里发生了什么吗?
原文由 SamYoungNY 发布,翻译遵循 CC BY-SA 4.0 许可协议
文档
使用以下任一命令:
npx create-react-app my-app
npm init react-app my-app
yarn create react-app my-app
如果
npm uninstall -g create-react-app
上述不起作用。 键入which create-react-app
以了解它的安装位置。我的安装在/usr/bin
文件夹中。然后做sudo rm -rf /usr/bin/create-react-app
。 (归功于下面的@v42 评论)