Check in this order (first match wins):
1. packageManager field in package.json — this is the authoritative declaration:
{
"packageManager": "pnpm@8.6.0"
}2. Lock files — if no packageManager field:
| Lock file | Package manager |
|---|---|
bun.lock |
bun (Bun 1.1+, plain text) |
bun.lockb |
bun (legacy binary format) |
pnpm-lock.yaml |
pnpm |
yarn.lock |
yarn |
package-lock.json |
npm |
3. Default — if neither, use npm.
Use $PM as the detected package manager throughout the workflow.
| Manager | Command | Verifies |
|---|---|---|
| npm | npm ping |
Registry connectivity |
| yarn | yarn --version |
CLI availability |
| pnpm | pnpm ping |
CLI + registry connectivity |
| bun | bun --version |
CLI only (no registry ping) |
| Manager | Command | JSON output |
|---|---|---|
| npm | npm audit |
npm audit --json |
| npm | npm audit fix |
(auto-fixes; no JSON mode) |
| yarn 1.x | yarn audit |
yarn audit --json |
| yarn 2+/berry | yarn npm audit |
yarn npm audit --json |
| pnpm | pnpm audit |
pnpm audit --json |
| pnpm 8+ | pnpm audit --fix |
(auto-fixes; no JSON mode) |
| bun | Not supported | - |
| Manager | Command |
|---|---|
| npm | npm outdated |
| yarn 1.x | yarn outdated |
| yarn 2+/berry | yarn outdated (v4+) or yarn upgrade-interactive (interactive, v2+); v2/v3 have no non-interactive outdated report |
| pnpm | pnpm outdated |
| bun | bun outdated |
| Manager | Latest version | Dist tags |
|---|---|---|
| npm | npm view <pkg> version |
npm view <pkg> dist-tags |
| yarn 1.x | yarn info <pkg> version |
yarn info <pkg> dist-tags |
| yarn 2+/berry | yarn info <pkg> --json |
yarn info <pkg> --json |
| pnpm | pnpm view <pkg> version |
pnpm view <pkg> dist-tags |
| bun | bunx npm-view <pkg> version |
- (not supported natively) |
| Manager | Install latest | Install specific |
|---|---|---|
| npm | npm install <pkg>@latest |
npm install <pkg>@<version> |
| yarn | yarn add <pkg>@latest |
yarn add <pkg>@<version> |
| pnpm | pnpm add <pkg>@latest |
pnpm add <pkg>@<version> |
| bun | bun add <pkg>@latest |
bun add <pkg>@<version> |
All package managers support $PM run <script> syntax:
npm run buildyarn run build(or justyarn build)pnpm run buildbun run build