Skip to content
Latchkey

Corepack: Enable pnpm and Yarn in CI

corepack enable installs shims for pnpm and yarn that read the "packageManager" field in package.json and run that exact version.

Corepack ships with Node.js and manages the package manager itself rather than the Node version. It pins pnpm/yarn through the packageManager field so every runner uses the same one, but you must enable it first.

What it does

Corepack is a Node-bundled tool that provides pnpm and yarn shims. corepack enable puts those shims on PATH; when you run pnpm, the shim reads "packageManager": "pnpm@9.1.0" from package.json and downloads/runs that exact version. corepack prepare can pre-fetch a version.

Common usage

bash
corepack enable                       # install pnpm/yarn shims
# package.json: "packageManager": "pnpm@9.1.0"
pnpm install --frozen-lockfile
# pre-download a specific version (e.g. for cache warming)
corepack prepare pnpm@9.1.0 --activate

Options

Command / flagWhat it does
corepack enableInstall pnpm/yarn shims onto PATH
corepack disableRemove the shims
corepack prepare <pkg>@<v>Pre-download a package manager version
--activateMake the prepared version the active default
packageManager (package.json)Pins the manager and version
COREPACK_ENABLE_DOWNLOAD_PROMPT=0Skip the first-run download prompt

In CI

Run corepack enable before any pnpm/yarn step (one-time per runner). Set COREPACK_ENABLE_DOWNLOAD_PROMPT=0 so the first download does not prompt. If corepack enable lacks permission to write into the Node bin dir, point COREPACK_HOME at a writable cache. Cache COREPACK_HOME to avoid re-downloading.

Common errors in CI

"Cannot find matching keyid" / "Signature verification failed" comes from an old Corepack with stale signing keys against a newer pnpm/yarn release; update Node/Corepack (npm i -g corepack@latest). "Error: EACCES: permission denied" on corepack enable means the Node bin dir is not writable; set COREPACK_HOME or run with appropriate permissions. "This project is configured to use yarn" means the packageManager field disagrees with the command you ran.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →