【问题标题】:React Js, Template Not Provided On npx create-react-app <app name>React Js,npx create-react-app <app name> 上未提供模板
【发布时间】:2022-01-20 01:04:27
【问题描述】:

我正在使用

npx create-react-app <app name>

我收到一个模板错误,没有提供,请执行以下操作 ->

npx uninstall -g create-react-app

嗯,我已经做到了,但没有帮助。我已经尝试更新当前的 nodejs 和 npm 版本,我已经完成了 nodejs 的全新安装,并且我已经清除了 npm 和 npx 缓存。我也尝试过使用特定的 create-react-app 版本,例如

npx create-react-app@latest(or some other version)

没有任何效果,没有提供任何模板,我有点迷茫。有谁知道另一种潜在的解决方法?如果存在这样的东西,我愿意手动下载包含 npx create-react-app 完成后内容的文件夹。

【问题讨论】:

标签: node.js reactjs


【解决方案1】:

React docs point out 可能是通过 Yarn 而不是 NPM 安装的 create-react-app,也可以试试这个:

yarn global remove create-react-app

This SO answer 建议如果npm uninstall -g create-react-app 不起作用,您可以手动查看create-react-app 是否以及在何处安装。

如果上述npm uninstall -g create-react-app 不起作用。键入which create-react-app 以了解它的安装位置。我的安装在/usr/bin 文件夹中。然后sudo rm -rf /usr/bin/create-react-app

您使用的是 Windows 还是 Mac/Linux? which 命令适用于 Mac/Linux,但不适用于 Windows。我不知道在 Windows 上执行此操作的最佳方法,但this thread 对 PowerShell 有一些建议。

我对@9​​87654333@ 命令的理解是它伪安装软件包(在本例中为create-react-app)以确保我们使用的是最新版本。它方便且推荐,但不是必需的。如果您仍然遇到问题,我会亲自尝试完全安装 create-react-app 看看我是否可以这样构建一个新项目:

npm install -g create-react-app
create-react-app my-app

【讨论】:

  • 这成功了!谢谢!
  • @ABadOmelette 我很高兴!请单击绿色复选标记将我的答案标记为“已接受”。这让我得到了答案,但更重要的是让我们都知道,当我们将来遇到类似问题时,这是一个可行的解决方案。您也可以“投票”我的回答。
猜你喜欢
  • 2020-03-29
  • 2021-03-03
  • 2022-12-06
  • 1970-01-01
  • 2022-01-17
  • 2020-08-11
  • 1970-01-01
相关资源
最近更新 更多