pnpm Cheat Sheet
Quick reference for pnpm: install / add / remove / update, scripts, workspaces, store & cache and config — focused on the GitHub-site pnpm repo workflow, with options and practical examples.
31 commands
Install & Manage
pnpm installInstall all dependencies declared in package.json, updating the lockfile as needed.
--frozen-lockfile (CI default in this repo); --prod; --offline; --ignore-scripts; --shamefully-hoist; --strict-peer-dependencies=false; --prefer-offline
pnpm install --frozen-lockfilepnpm add <pkg>Add a runtime dependency and write to package.json.
-D / --save-dev; -E / --save-exact; -O / --save-optional; -P / --save-prod; -g global; --workspace-root add at workspace root
pnpm add -D vitest @types/nodepnpm add -g <pkg>Install a global tool (e.g. TypeScript, ESLint, tsx) onto the path.
-g; --global-prefix; --reporter append|ndjson
pnpm add -g typescript tsxpnpm remove <pkg>Remove a dependency from the project and the lockfile.
-D from devDependencies; -g from globals; --filter pkg remove from one workspace only
pnpm remove lodash && pnpm remove -F web -D @types/jestpnpm update / pnpm update -LUpdate dependencies within the semver range; -L / --latest upgrades to the newest version.
-L / --latest; -i / --interactive; --workspace-root; --filter
pnpm update -i vue && pnpm update -L @nuxt/i18npnpm outdatedShow outdated packages alongside current / wanted / latest versions.
--long; --recursive / -r; --filter
pnpm outdated -r --longpnpm listList installed packages and a tree of what depends on them.
--depth 0 only direct; --prod / --dev; -r recursive; --json | jq
pnpm list --depth 0 --prod | head -20pnpm audit / pnpm audit --fixRun the npm-style security advisory check against the lockfile.
--prod only production; --json
pnpm audit --json | jq '.metadata.vulnerabilities'pnpm dedupePrune the lockfile/dependency tree by hoisting to a single version where possible.
--check; --strict-peer-dependencies=false
pnpm dedupe --checkpnpm rebuildRebuild native dependencies (post-build / after Node version bump).
--reporter; --recursive; --filter
pnpm rebuild -r && pnpm rebuild esbuildpnpm approve-buildsApprove build scripts for native packages (e.g. esbuild, sharp, @swc/core).
interactive prompts; can also be set via package.json#pnpm.onlyBuiltDependencies
pnpm approve-builds --yes esbuild @parcel/watcherpnpm importImport an existing package-lock.json / yarn.lock into a pnpm-lock.yaml.
import; n/a other params
pnpm import --no-lockfileRun & DX
pnpm run <script>Run a script defined in package.json#scripts.
-r / --recursive run in every package; --filter / -F target one; --parallel; --no-color
pnpm run dev && pnpm -F src/www run buildpnpm dlx <pkg>Fetch a package from the registry and run its binary without permanently installing.
dlx pkg args; --package extra pkg; --silent
pnpm dlx create-vite@latest my-app --template vue-ts && pnpm dlx vitest --runpnpm exec <cmd>Run a command in the project's context (PATH includes .node_modules/.bin).
exec ...; --filter target workspace; --recursive; --parallel
pnpm exec vitest run && pnpm exec -- tsc --noEmit -p src/www/tsconfig.jsonpnpm create <name>Scaffold a new project from a create-* style package.
create [name] [args]; -y / --yes
pnpm create nuxt my-app && cd my-app && pnpm installWorkspace
pnpm -r <cmd>Recursive — run a pnpm action across every package in the workspace.
-r run build; --parallel; --topology sort; --order
pnpm -r --filter "./packages/**" run build --silentpnpm --filter <pkg>Target one package by name, directory, glob or ./relative-path.
--filter pkg | --filter ./packages/foo | --filter {pkg} strict name only; -F alias
pnpm --filter trowsoft-pdf-merge run build && pnpm -F "./packages/tools/*" outdatedpnpm add ... -w / --workspace-rootAdd a hoisted dev dependency that's shared across the workspace.
-w / --workspace-root; -D to devDeps
pnpm add -Dw typescriptStore & Cache
pnpm store pathPrint the location of pnpm's content-addressable store (deduped across projects).
store path; --virtual-store-dir DIR
pnpm store path && du -sh $(pnpm store path)pnpm store pruneRemove unreferenced packages from the store (reduces disk usage).
store prune; --force skip prompt
pnpm store prunepnpm cache list / cache deleteList or delete entries in pnpm's metadata cache.
cache list; cache delete <pkg>@<ver>; --registry
pnpm cache list vitest@latestConfig & Info
pnpm config get|set <key> [value]Read or write to the user's/global/store/project pnpm config.
config get key; config set key val; --location project|user|global
pnpm config set registry https://registry.npmjs.org/ --location user && pnpm config get registrypnpm config delete|listList all effective config keys, or delete one.
config list --location project; config delete key
pnpm config list --location projectpnpm why <pkg>Explain why a package is in node_modules — show the chain of dependants.
--prod; --dev; -r; --filter
pnpm why -r vue && pnpm why lodash -rpnpm link / pnpm link --globalSymlink a local package into the current project, or install a global package locally.
link (uses ./); link --global <pkg>; --dir
cd packages/tools/foo && pnpm link --global && cd my-app && pnpm link --global fooPublish & Pack
pnpm publishPublish the current package to the configured registry.
--dry-run; --tag alpha|beta|next; --access public|restricted; --otp N; --filter
pnpm publish --dry-run --tag canary --access publicpnpm packCreate a tarball of the package without publishing (for upload elsewhere).
--pack-gzip-level 0..9; --pack-destination DIR
pnpm pack --pack-destination ./releaseRecurring Workflows
pnpm recursive list / pnpm -r whyInspect the dependency tree across all workspaces at once.
pnpm recursive list --depth 0pnpm run --filter <pkg> testRun a script in just one workspace — perfect for fine-grained CI.
--filter with dependencies/dependents; --parallel
pnpm --filter "trowsoft-pdf-*" run build --parallelpnpm sync:tools / pnpm build:toolsRepo helpers from this site — sync tool translations into the Nuxt app, then build tool bundles.
pnpm sync:tools && pnpm build:toolsCheatsheet version 1.0.0
Covers pnpm 9+