未使用create-react-app提供模板 [英] Template not provided using create-react-app
问题描述
当我在终端中键入 create-react-app my-app
命令时,它似乎可以正常工作-成功下载所有库等。在该过程结束时但是我收到一条消息,提示未提供模板
。
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
.
输入
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中:
In package.json of my-app
:
"dependencies": {
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-scripts": "3.3.0" <-- up-to-date
}
我签出了CRA 更改日志,它似乎已添加了对自定义模板的支持-但它看起来不像命令 create-react-app my-app
将会更改。
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.
有什么想法吗?
推荐答案
如果您以前通过
npm install -g create-react-app $ c在全球范围内安装了
create-react-app
$ c>,我们建议您使用npm uninstall -g create-react-app
卸载软件包,以确保npx
始终使用最新版本。
If you've previously installed
create-react-app
globally vianpm install -g create-react-app
, we recommend you uninstall the package usingnpm uninstall -g create-react-app
to ensure thatnpx
always uses the latest version.
使用以下任一命令:
-
npx create-react-app my-app
-
npm init反应-app my-app
-
yarn创建react-app my-app
npx create-react-app my-app
npm init react-app my-app
yarn create react-app my-app
如果上述 npm uninstall -g create-react-app
不起作用。
键入哪个create-react-app
知道它的安装位置。我的被安装在 / usr / bin
文件夹中。然后执行 sudo rm -rf / usr / bin / create-react-app
。 (以下为@ v42评论的信用)
if npm uninstall -g create-react-app
stated above does not work.
Type which create-react-app
to know where it is installed. Mine was installed in /usr/bin
folder. Then do sudo rm -rf /usr/bin/create-react-app
. (Credit to @v42 comment below)
这篇关于未使用create-react-app提供模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!