Skip to content

Commit

Permalink
doc: update corepack.md to account for 0.20.0 changes
Browse files Browse the repository at this point in the history
PR-URL: nodejs#49486
Refs: nodejs/corepack#291
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
aduh95 authored and alexfernandez committed Nov 1, 2023
1 parent 4506b75 commit 87de55d
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions doc/api/corepack.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -52,35 +52,43 @@ 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

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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 87de55d

Please sign in to comment.