When running commands on a workspace, it is possible to limit them to a subset of packages.
pnpm supports package selectors that can be used together with its recursive
commands:
pnpm recursive <cmd> [arg..] -- [selector...]
# or
pnpm recursive <cmd> [arg..] --filter <selector-1> --filter <selector-2>...
When packages in the workspace are filtered, every package is taken that matches at least one of the selectors.
Selectors that start with ./
are selectors by filesystem path. Selectors by path don't support globs.
Select all packages in the packages
folder:
pnpm recursive install -- ./packages
Selectors that don't start with ./
are selectors by package name.
To select an exact package, just specify its name. For insance,
the following command will be applied on foo
, bar
and @pnpm/config
:
pnpm recursive install -- foo bar @pnpm/config
To select a package and its dependencies (direct and non-direct), suffix the package name with 3 dots: <pkg name>...
.
For instance, the next command will run installation in all dependencies of foo
and in foo
:
pnpm recursive install -- foo...
To select a package and its dependent packages (direct and non-direct), prefix the package name with 3 dots: ...<pkg name>
.
For instance, the next command will run installation in all dependents of foo
and in foo
:
pnpm recursive install -- ...foo
To select all packages that are between two packages in the dependency graph, the two package names
should be concatenated with ..
: <pkg1>..<pkg2>
.
The following command is performed on all transitive deps of foo
and bar
(including foo
and bar
):
pnpm recursive install -- foo..bar
Selecting all dependents and dependencies: <cmd> -- ...<pkg>...
Selecting dependencies of pkg2
and transitive dependencies between pkg1
ang pkg2
: <cmd> -- pkg1..pkg2...