Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: update corepack.md to account for 0.20.0 changes #49486

Merged
merged 3 commits into from
Sep 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 [email protected] # 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 [email protected] --activate
corepack install --global [email protected]
```

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
aduh95 marked this conversation as resolved.
Show resolved Hide resolved
[`package.json`]: packages.md#nodejs-packagejson-field-definitions
[pnpm]: https://pnpm.js.org
[supported binaries]: #supported-package-managers
Expand Down