diff --git a/doc/api/corepack.md b/doc/api/corepack.md index c023a24183348e..b9c3ddca09c78c 100644 --- a/doc/api/corepack.md +++ b/doc/api/corepack.md @@ -12,7 +12,7 @@ added: > Stability: 1 - Experimental -_[Corepack][]_ is an experimental tool to help with +_[Corepack][Corepack repository]_ is an experimental tool to help with managing versions of your package managers. It exposes binary proxies for each [supported package manager][] that, when called, will identify whatever package manager is configured for the current project, transparently install @@ -52,23 +52,31 @@ 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. +You can use [`corepack use`][] to ask Corepack to update your local +`package.json` to use the package manager of your choice: + +```bash +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 +``` + ### Upgrading the global versions When running outside of an existing project (for example when running `yarn init`), Corepack will by default use predefined versions roughly corresponding to the latest stable releases from each tool. Those versions can -be overridden by running the [`corepack prepare`][] command along with the +be overridden by running the [`corepack install`][] command along with the package manager version you wish to set: ```bash -corepack prepare yarn@x.y.z --activate +corepack install --global yarn@x.y.z ``` Alternately, a tag or range may be used: ```bash -corepack prepare pnpm@latest --activate -corepack prepare yarn@stable --activate +corepack install --global pnpm@* +corepack install --global yarn@stable ``` ### Offline workflow @@ -76,11 +84,11 @@ corepack prepare yarn@stable --activate Many production environments don't have network access. Since Corepack usually downloads the package manager releases straight from their registries, it can conflict with such environments. To avoid that happening, call the -[`corepack prepare`][] command while you still have network access (typically at +[`corepack pack`][] command while you still have network access (typically at the same time you're preparing your deploy image). This will ensure that the required package managers are available even without network access. -The `prepare` command has [various flags][]. Consult the detailed +The `pack` command has [various flags][]. Consult the detailed [Corepack documentation][] for more information. ## Supported package managers @@ -118,14 +126,15 @@ install. To avoid this problem, consider one of the following options: override binaries, but you'll erase the Corepack ones in the process. (Run [`corepack enable`][] to add them back.) -[Corepack]: https://github.com/nodejs/corepack [Corepack documentation]: https://github.com/nodejs/corepack#readme [Corepack repository]: https://github.com/nodejs/corepack [Yarn]: https://yarnpkg.com [`"packageManager"`]: packages.md#packagemanager [`corepack disable`]: https://github.com/nodejs/corepack#corepack-disable--name [`corepack enable`]: https://github.com/nodejs/corepack#corepack-enable--name -[`corepack prepare`]: https://github.com/nodejs/corepack#corepack-prepare--nameversion +[`corepack install`]: https://github.com/nodejs/corepack#corepack-install--g--global---all--nameversion +[`corepack pack`]: https://github.com/nodejs/corepack#corepack-pack---all--nameversion +[`corepack use`]: https://github.com/nodejs/corepack#corepack-use-nameversion [`package.json`]: packages.md#nodejs-packagejson-field-definitions [pnpm]: https://pnpm.js.org [supported binaries]: #supported-package-managers