未使用 create-react-app 提供模板 [英] Template not provided using create-react-app

查看:31
本文介绍了未使用 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 changelog似乎为自定义模板添加了支持 - 但是它看起来不像命令 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.

知道这里发生了什么吗?

Any idea what is going on here?

推荐答案

如果您之前已经通过 npm install -g create-react-app 全局安装了 create-react-app,我们建议您使用 卸载包npm uninstall -g create-react-app 确保 npx 始终使用最新版本.

If you've previously installed create-react-app globally via npm install -g create-react-app, we recommend you uninstall the package using npm uninstall -g create-react-app to ensure that npx always uses the latest version.

文档

使用以下任一命令:

  • 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 评论)

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆