corepack prepare: Usage, Options & Common CI Errors
corepack prepare fetches and activates a specific Yarn or pnpm version.
corepack prepare downloads an exact package-manager version and, with --activate, makes it the default the shims resolve to. It is how you pin pnpm or Yarn deterministically in CI.
What it does
corepack prepare <pm>@<version> --activate downloads that package manager into Corepack's cache and sets it as the active version. It pairs with the packageManager field for full reproducibility, and can pre-warm the cache (corepack prepare --all) for offline use in air-gapped CI.
Common usage
corepack enable
corepack prepare pnpm@9.5.0 --activate
corepack prepare yarn@4.3.1 --activate
corepack prepare --all # pre-cache for offline use
pnpm --version # -> 9.5.0Common errors in CI
"Error when performing the request" / "request to https://registry.npmjs.org ... failed" means Corepack could not reach the registry to download the version - check proxy/network or pre-cache with --all. "Cannot find matching keyid" / "Signature verification failed" is an older Corepack rejecting a newer package-manager signature; upgrade Node/Corepack. Without --activate, prepare only caches the version and does not switch to it, so the shim may still run a different one.
Options
| Item | What it does |
|---|---|
| <pm>@<ver> --activate | Download and make it the active version |
| --all | Pre-cache all package managers (offline prep) |
| (no --activate) | Cache only; does not switch the active version |