What Corepack Does

Corepack 3,816 is a small Node.js 2,131 program that installs shims: pnpm 69,400 , yarn and friends on your PATH are Corepack scripts, not the real tools. When you run one, Corepack reads the nearest package.json, decides which version the project wants, downloads it once into ~/.cache/node/corepack, and runs it. corepack enable creates the shims; this book's machine runs Corepack 0.36.0.

The shims, and running any version on demandShell
readlink -f "$(which pnpm)" "$(which yarn)"
pnpm --version
corepack pnpm@11.0.0 --version
Output
/usr/lib/node_modules/corepack/dist/pnpm.js
/usr/lib/node_modules/corepack/dist/yarn.js
12.6.0
11.0.0

Outside a pinned project the shim runs Corepack's default (pnpm 12.6.0 here); corepack <tool>@<version> runs any other version, as Yarn Classic's Legacy did for Yarn Classic 11,798 . Downloads are checked against the registry's signatures or the hash pinned in package.json.