corepack enable: Pin Your Package Manager
Corepack activates the package manager and version your repo declares.
The packageManager field plus corepack enable guarantees CI uses the same yarn/pnpm version as developers, eliminating a class of version-mismatch errors.
Common usage
corepack enable- activate shims"packageManager": "pnpm@9.1.0"in package.jsoncorepack prepare <pm>@<v> --activate
Example in CI
Enable before install so the pinned manager is used.
shell
corepack enable && pnpm install --frozen-lockfileIn CI
With Corepack you do not need a separate setup-pnpm/yarn step. The packageManager field is the single source of truth.
Key takeaways
- Corepack pins yarn/pnpm via
packageManager. - Run
corepack enablebefore install. - No separate setup step needed.