【问题标题】:Is there any way to use NPM and not Yarn while creating a project with create-react-app在使用 create-react-app 创建项目时有什么方法可以使用 NPM 而不是 Yarn
【发布时间】:2020-09-05 08:36:58
【问题描述】:

我同时安装了 Yarn 和 NPM,但每当我尝试 create-react-app 时,它都会自动使用 Yarn。

我尝试运行 create-react-app app --use-npm,但随后它使用旧版本的节点和 NPM 创建了它。

然后我尝试更新节点和 NPM 版本并运行 npm -v,它显示了最新版本,但在运行 create-react-app app --use-npm 后再次创建它是用没有 create-react-app 最新功能的旧版本创建的。

我想使用 NPM 并使用所有最新版本的 node 和 NPM 创建 react 应用程序,而无需从我的系统中删除 Yarn。我哪里出错了,可能的解决方案是什么?

【问题讨论】:

    标签: node.js reactjs create-react-app yarnpkg


    【解决方案1】:

    当你想使用npm时,进入项目文件夹:

    1. 删除yarn.lock
    2. 删除node_modules
    3. 运行npm install

    它将使用您的系统上安装的最新npm

    【讨论】:

      【解决方案2】:

      试试npx create-react-app my-app

      【讨论】:

      • running "npx create-react-app my-app" 使用 yarn 而不是 npm 创建了应用程序。我想为此使用 npm。
      • 尝试移除 yarn,然后用 npm create-react-app。
      猜你喜欢
      • 2020-09-08
      • 2020-06-14
      • 2019-03-09
      • 2021-12-02
      • 2020-10-10
      • 2022-01-23
      • 1970-01-01
      • 2020-10-01
      • 1970-01-01
      相关资源
      最近更新 更多