yarn workspaces foreach — Yarn CLI reference

Run a command in multiple workspaces

Docs/Reference/CLI/workspaces/foreach

yarn workspaces foreach

Run a command in multiple workspaces

yarn workspaces foreach <COMMAND> <ARGS…>

This command selects workspaces from the project and runs the given command in each of them. Workspaces can be selected explicitly, by dependency relationship, by change detection, or by include/exclude patterns.

By default commands run sequentially. Use -p,--parallel to run them concurrently, and --topological to respect workspace dependency order.

When both --follow-dependents and --follow-dependencies are set, the dependents are added first and the dependencies are then followed from the whole resulting set, so the selection contains everything needed to build each dependent (equivalent to pnpm’s --filter '...{pkg}...').

#--all, -Aboolean

Run the command in every workspace

#--fromboolean

Start selection from workspaces matching these patterns

#--sincestring

Select workspaces changed since a ref, or since the configured base refs when no ref is provided

#--headboolean

Compare against this ref rather than the working tree when used with --since

#--recursiveboolean

Include workspace dependencies of the selected workspaces

#--follow-dependenciesboolean

Follow dependencies when expanding the workspace selection

#--follow-dependentsboolean

Follow dependents when expanding the workspace selection

#--followed-dependenciesboolean

Dependency kinds followed by --follow-dependencies

#--includeboolean

Include only workspaces matching these patterns

#--excludeboolean

Exclude workspaces matching these patterns

#--parallel, -pboolean

Run commands in parallel

#--interlaced, -iboolean

Print output from parallel commands as it is produced

#--jobs, -jboolean

Maximum number of parallel jobs, or unlimited

#--topologicalboolean

Run workspaces in topological order

#--verbose, -vboolean

Increase output verbosity; can be repeated

#--privateboolean

Include private workspaces