Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
pnpm 10.x reference skill covering workspaces, catalogs, patches, peer deps, overrides, and CI/CD caching strategies.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/core-cli.md
1---2name: pnpm-cli-commands3description: Essential pnpm commands for package management, running scripts, workspaces, publishing, and runtimes4---56# pnpm CLI Commands78pnpm provides a comprehensive CLI. Commands resemble npm/yarn but with unique features.910## Installation Commands1112```bash13pnpm install # install all deps (alias: pnpm i)14pnpm add <pkg> # production dependency15pnpm add -D <pkg> # devDependency (also -d)16pnpm add -O <pkg> # optionalDependency (also -o)17pnpm add -E <pkg> # exact version (also -e)18pnpm add <pkg>@<version>19pnpm remove <pkg> # aliases: rm, uninstall, un20pnpm update # alias: up21pnpm update --latest # ignore semver ranges (-L)22pnpm update -i # interactive23```2425### Clean / reproducible installs2627```bash28pnpm install --frozen-lockfile # fail if lockfile would change (auto in CI)29pnpm ci # clean install = pnpm clean + install --frozen-lockfile30pnpm clean # remove node_modules in all workspace projects (alias: purge)31pnpm clean --lockfile # also delete pnpm-lock.yaml32```3334> Since v11, an integrity mismatch against the lockfile is a hard error (`ERR_PNPM_TARBALL_INTEGRITY`). Use `pnpm install --update-checksums` only after verifying the new bytes. In CI, pnpm also fails on lockfiles written by a newer pnpm major.3536## Script Commands3738```bash39pnpm run <script> # or just: pnpm <script>40pnpm run build -- --watch41pnpm run --if-present build42pnpm set-script test "vitest run" # add/update a scripts entry (alias: ss)43pnpm exec <cmd> # run a local binary, e.g. pnpm exec eslint .44```4546- **Hidden scripts:** names starting with `.` (e.g. `.helper`) can't be run directly, only called from other scripts.47- **Built-in vs script conflict:** `clean`, `setup`, `deploy`, `rebuild` prefer a same-named `package.json` script. Force the built-in with `pnpm pm <name>` (e.g. `pnpm pm clean`).4849### dlx / pnx — run without installing5051```bash52pnx create-vite my-app # pnx == pnpm dlx == pnpx53pnpm dlx degit user/repo dest54pnx shx@catalog: # catalog: protocol supported55pnx --package=@scope/tool tool --help56```5758> `dlx`/`pnx` honor supply-chain settings (`minimumReleaseAge`, `trustPolicy`) and use the global virtual store by default in v11.5960## Workspace Commands6162```bash63pnpm -r run <script> # run in all packages (alias: --recursive)64pnpm --filter <pattern> run <script>65pnpm --filter "./packages/**" run build66pnpm --filter "@myorg/*" run lint67pnpm -r --parallel run dev68```6970### Filter patterns7172```bash73pnpm --filter <pkg-name> <cmd> # by name (-F shorthand)74pnpm --filter "./packages/core" test75pnpm --filter "...@scope/app" build # package + its dependencies76pnpm --filter "@scope/core..." test # package + its dependents77pnpm --filter "...[origin/main]" build # changed since git ref78```7980## Patches8182```bash83pnpm patch <pkg>@<version> # opens an editable copy, prints a path84pnpm patch-commit <path> # writes patches/*.patch and records it85pnpm patch-remove <pkg>@<version>86```8788## Linking local packages8990```bash91pnpm link <dir> # link a path into this project's node_modules (path only!)92pnpm add -g . # register the current package's bins globally93```9495> Breaking in v11: `pnpm link` accepts **only relative/absolute paths** (no global store resolution, no `--global`, no bare `pnpm link`). Use `pnpm add -g .` to expose bins system-wide.9697## Global packages (v11 isolated installs)9899```bash100pnpm add -g typescript prettier # each gets its own isolated install dir101pnpm add -g eslint,prettier # comma = ONE shared install group102pnpm add -g --allow-build=esbuild esbuild103pnpm remove -g <pkg>104pnpm list -g105pnpm bin -g # show global bin dir ($PNPM_HOME/bin)106```107108> `pnpm install -g` (no args) is not supported. After upgrading to v11 run `pnpm setup` so `$PNPM_HOME/bin` is on PATH.109110## Runtimes (Node/Deno/Bun)111112```bash113pnpm runtime set node 22 -g # install & expose node (alias: rt)114pnpm runtime set node lts -g115pnpm runtime set deno 2 -g116pnpm install --no-runtime # skip installing devEngines.runtime entries117```118119## Store management120121```bash122pnpm store path # store location (prints removed size after prune)123pnpm store prune # GC unreferenced packages (+ global virtual store links)124pnpm store status125```126127## Inspection / registry128129```bash130pnpm list # alias: ls131pnpm why <pkg> # reverse-dependency tree (dedupes subtrees)132pnpm why --find-by=<finder> # custom finder from .pnpmfile.mjs133pnpm outdated134pnpm audit135pnpm peers check # report unmet/missing peers from the lockfile136pnpm view <pkg> [field] # registry metadata (aliases: info, show)137pnpm whoami138pnpm rebuild139pnpm import # create pnpm-lock.yaml from npm/yarn lockfile140pnpm dedupe141```142143## Publishing144145```bash146pnpm pack147pnpm publish -r --no-git-checks148pnpm version patch|minor|major|2.0.0 # bump version, commit + tag (v11)149pnpm version prerelease --preid beta150pnpm deprecate <pkg>@<range> "message"151pnpm dist-tag add <pkg>@<version> <tag>152pnpm unpublish <pkg>@<version> # discouraged; prefer deprecate153pnpm sbom --sbom-format cyclonedx # SBOM: cyclonedx (1.7) | spdx (2.3)154pnpm stage publish ... # staged publishing (defer 2FA)155```156157## Maintenance & version management158159```bash160pnpm self-update [<version>] # updates the packageManager pin, or installs globally161pnpm with current install # run a specific pnpm version for one command162pnpm with 11.0.0 install163pnpm approve-builds [--all] # review dependency build scripts (writes allowBuilds)164```165166## Useful Flags167168```bash169pnpm install --ignore-scripts170pnpm install --prefer-offline171pnpm install --prod # -P, omit devDependencies172pnpm install --no-optional173pnpm install --strict-peer-dependencies174```175176## Key Points177178- `pnpm ci` = clean + frozen install; CI auto-enables frozen-lockfile.179- `dlx`/`pnpx` are aliases of `pnx`; global installs are now isolated per package (comma-list to share).180- `pnpm link` only takes paths; use `pnpm add -g .` for global bins.181- Manage Node/Deno/Bun with `pnpm runtime set`; skip them at install with `--no-runtime`.182- New publishing/registry commands: `version`, `view`, `whoami`, `deprecate`, `dist-tag`, `unpublish`, `sbom`, `stage`.183184<!--185Source references:186- https://pnpm.io/cli/install187- https://pnpm.io/cli/add188- https://pnpm.io/cli/run189- https://pnpm.io/filtering190- https://pnpm.io/cli/link191- https://pnpm.io/global-packages192- https://pnpm.io/cli/runtime193- https://pnpm.io/cli/version194- https://pnpm.io/cli/with195- https://pnpm.io/cli/sbom196-->197