配置包


¥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