Skip to main content

CLI 默认包管理器不再是 yarn

¥The CLI default package manager is not yarn anymore

在 Strapi v5 中,用于运行依赖安装的命令是实际安装它们的命令。

¥In Strapi v5, the command used to run dependencies installation is the one used to actually install them.

此页面是 重大变更数据库 的一部分,提供有关重大更改的信息以及从 Strapi v4 迁移到 Strapi 5 的其他说明。

¥This page is part of the breaking changes database and provides information about the breaking change and additional instructions to migrate from Strapi v4 to Strapi 5.

\🔌 此重大更改是否会影响插件?\
\🤖 此重大更改是否由 codemod 自动处理?\

重大更改描述

¥Breaking change description

在 Strapi v4 中

¥In Strapi v4

以下所有命令都尝试使用 yarn 安装应用依赖:

¥All the following commands try to use yarn to install the application dependencies:

  • npx create-strapi-app

  • npm create strapi-app

  • yarn create strapi-app

  • yarn dlx …

在 Strapi 5 中

¥In Strapi 5

Strapi 会检测你用于运行 CLI 的包管理器,并使用此包管理器安装依赖。

¥Strapi detects what package manager you are using to run the CLI, and uses this package manager to install dependencies.

迁移

¥Migration

注意

¥Notes

  • 由于 Strapi 检测用于运行命令的包管理器并使用它来安装依赖,这意味着将发生以下示例用例:

    ¥Since Strapi detects the package manager used to run the command and uses it to install dependencies, this means the following example use cases will happen:

    • npx create-strapi-app 使用 npm 安装依赖

      ¥npx create-strapi-app installs the dependencies with npm

    • npm create … 使用 npm 安装依赖

      ¥npm create … installs the dependencies with npm

    • yarn create … 使用 yarn 安装依赖

      ¥yarn create … installs the dependencies with yarn

    • yarn dlx … 使用 yarn 安装依赖

      ¥yarn dlx … installs the dependencies with yarn

    • pnpm create … 使用 pnpm 安装依赖

      ¥pnpm create … installs the dependencies with pnpm

    • pnpm dlx … 使用 pnpm 安装依赖

      ¥pnpm dlx … installs the dependencies with pnpm

手动程序

¥Manual procedure

拥有现有项目的用户不受影响。只有执行特定自动化和脚本的用户或习惯于运行 create-strapi-app 命令并期望默认使用 yarn 的插件开发者才会受到影响。

¥Users with existing projects are not impacted. Only users doing specific automation and scripts or plugin developers that are used to running a create-strapi-app command and expect yarn to be used by default will be impacted.

例如,如果你想使用 npx 但仍强制使用 yarn 安装依赖,请添加 --use-yarn 标志。有关可能的标志的更多信息,请参阅 CLI 安装参考

¥If, for instance, you want to use npx but still enforce using yarn to install dependencies, add a --use-yarn flag. Additional information about the possible flags is available in the CLI installation reference.