【问题标题】:安装 yarn 和 npx 工作后 create-react-app 不工作
【发布时间】:2022-01-22 23:55:09
【问题描述】:

我是一个新的 mac 用户,我刚买了一个 mac m1,我遇到了一个奇怪的问题。 当我尝试运行命令时,我安装了 yarn v3

yarn create-react-app app 

它给了我这个错误

Usage Error: The project in /Users/home/package.json doesn't seem to have been installed - running an install there might help

【问题讨论】:

  • yarn/npx create-react-app app 应该已经在您运行命令的目录中创建了一个名为 app 的项目。生成项目后,您需要 cd 进入并运行 npm/yarn start
  • 这适用于 windows:yarn create react-app my-app. Mac 有什么不同吗?
  • @ArmanEbrahimi 这是我的笔记本电脑中的一个错误我有旧版本的 yarn v 1.22 但我想将它升级到 v3 以便能够使用最新的包

标签: reactjs yarnpkg


【解决方案1】:

'create-react-app' 是一个使用一些样板代码快速创建 React 应用程序的工具包。

您可以分两步创建一个 React 应用:

第 1 步:安装 create-react-app

第 2 步:使用 create-react-app 创建您的应用。

对于第 1 步: 要安装 create-react-app,请使用以下命令:

yarn global add create-react-app

对于第 2 步:使用它来创建您的 React 应用程序:

create-react-app app

您也可以在不全局安装“create-react-app”包的情况下创建应用:

npx create-react-app <app name>

供您参考:https://reactjs.org/docs/create-a-new-react-app.html#create-react-app

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-02-05
    • 1970-01-01
    • 2021-09-11
    • 1970-01-01
    • 2021-06-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多