配置包


🌐 Configuring a package

Corepack 代理将会在你当前的目录层级中找到最接近的 package.json 文件,以提取其 "packageManager" 属性。

🌐 The Corepack proxies will find the closest package.json file in your current directory hierarchy to extract its "packageManager" property.

如果该值对应 支持的包管理器,Corepack 将确保对相关二进制文件的所有调用都运行在所请求的版本上,如有需要会按需下载,并在无法成功获取时中止。

🌐 If the value corresponds to a supported package manager, Corepack will make sure that all calls to the relevant binaries are run against the requested version, downloading it on demand if needed, and aborting if it cannot be successfully retrieved.

你可以使用 corepack use 来让 Corepack 更新本地的 package.json,以使用你选择的包管理器:

🌐 You can use corepack use to ask Corepack to update your local package.json to use the package manager of your choice:

corepack use pnpm@7.x # sets the latest 7.x version in the package.json
corepack use yarn@* # sets the latest version in the package.json