pnpm --filter selects workspace packages by name, dependency relation, directory or git changes
Answer: pnpm --filter <selector> <command> (or -F) restricts a command to a subset of workspace packages. pnpm supports a rich selector syntax for picking packages by name or by relation.
Selector cheat sheet
| Selector | Selects | |---|---| | "@babel/core", "@babel/", "core" | a package by name, or a set by pattern | | foo... | foo and its dependencies (direct and non-direct) | | "foo^..." | only foo's dependencies | | ...foo | foo and the packages dependent on it | | "...^foo" | only the dependents of foo | | "{packages/**}" or ./<glob> | packages under a directory glob | | "[origin/master]" | packages changed since that commit or branch |
pnpm --filter foo... test
pnpm --filter "...{packages/**}[origin/master]" test
Details
- The scope is optional:
--filter=corepicks@babel/coreifcoreis not found. If several packages share the name, such as@babel/coreand@types/core, filtering without scope will pick nothing. - Directory selectors combine with
...and with[<since>], so one command can test all changed projects inside a directory plus their dependents. - The
[<since>]selector may be suffixed or prefixed with...to include dependencies or dependents.
See also
Claims
- id: C1 claim: Filtering restricts commands to subsets of packages. source: S2 evidence: "Filtering allows you to restrict commands to specific subsets of packages."
- id: C2 claim: A trailing ellipsis selects a package and its dependencies. source: S2 evidence: "suffix the package name with an ellipsis"
- id: C3 claim: The since selector picks packages changed since a commit or branch. source: S2 evidence: "Selects all the packages changed since the specified commit/branch."
- id: C4 claim: Filtering without scope can pick nothing when names collide. source: S1 evidence: "then filtering without scope will pick nothing"
Sources
- [S1] Filtering. pnpm docs. https://pnpm.io/filtering . License: MIT. Accessed 2026-11-18.
- [S2] Filtering (source page). pnpm/pnpm.io (GitHub). https://github.com/pnpm/pnpm.io/blob/main/docs/filtering.md . License: MIT. Accessed 2026-11-18.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: pnpm docs, Filtering; pnpm/pnpm.io (GitHub), Filtering (source page). MIT (https://raw.githubusercontent.com/pnpm/pnpm.io/main/LICENSE). Copyright pnpm contributors. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: pnpm docs, Filtering; pnpm/pnpm.io (GitHub), Filtering (source page). MIT (https://raw.githubusercontent.com/pnpm/pnpm.io/main/LICENSE). Copyright pnpm contributors.
Cite this
iinventedlight. 2026. "pnpm --filter selects workspace packages by name, dependency relation, directory or git changes." iinventedlight Library, iil:note:0e9q8yj4, version of 2026-11-18. https://iinventedlight.com/library/notes/pnpm-filtering/. License: CC-BY-4.0.
@misc{iil_note_0e9q8yj4,
author = {{iinventedlight}},
title = {{pnpm --filter selects workspace packages by name, dependency relation, directory or git changes}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-18},
url = {https://iinventedlight.com/library/notes/pnpm-filtering/},
note = {Permanent ID iil:note:0e9q8yj4. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- pnpm-filtering.table.json (table; CC-BY-4.0)
- pnpm-filtering.schema.json (schema; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/pnpm-filtering.md.