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.

 Is this breaking change affecting plugins?No
 Is this breaking change automatically handled by a codemod?No

重大变更描述

🌐 Breaking change description

在 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 中

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 检测用于运行命令的包管理器并使用它来安装依赖,这意味着将发生以下示例用例:
    • npx create-strapi-app 使用 npm 安装依赖
    • npm create … 使用 npm 安装依赖
    • yarn create … 使用 yarn 安装依赖
    • yarn dlx … 使用 yarn 安装依赖
    • pnpm create … 使用 pnpm 安装依赖
    • pnpm dlx … 使用 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.