yarn tasks run — Yarn CLI reference

Run a task

Docs/Reference/CLI/tasks/run

yarn tasks run

Run a task

yarn tasks run <NAME> <ARGS…>

This command runs a task (and its dependencies, in the right order) from the taskfile of the current workspace, or across many workspaces at once when a workspace selection option is set.

Workspace selection uses the same options as yarn workspaces foreach:

  • -A,--all runs the task in every workspace declaring it.

  • --from <glob> runs it in the workspaces matching the glob (ident glob like @scope/* or path glob like ./packages/*); can be repeated.

  • --since [ref] runs it in the workspaces changed since the ref, or since the configured base refs (changesetBaseRefs) when no ref is provided. The working tree is compared to the base unless --head <ref> is set. Unset bounds are read from YARN_CHANGESET_BASE / YARN_CHANGESET_HEAD (or TURBO_SCM_BASE / TURBO_SCM_HEAD).

  • --follow-dependencies adds the transitive workspace dependencies of the selection, and --follow-dependents adds its dependents. When both are set, dependencies are followed from the dependents too (pnpm’s --filter '...{pkg}...'). --recursive follows dependents when combined with --since (so --since --recursive selects all the affected workspaces), and dependencies otherwise. --followed-dependencies restricts the traversal to prod or dev dependencies. Without -A/--from/--since, they apply to the current workspace.

  • --include/--exclude <glob> and --no-private filter the final selection.

All selected tasks are resolved into a single deduplicated graph. Use --only to skip cross-workspace dependencies (e.g. *:build) pointing outside of the selection. When running across workspaces the first failure cancels the run unless --continue is set.

The daemon limits the number of processes running at once across all runs, according to the taskConcurrency setting (CPU count by default).

Several tasks can be run at once by separating them with commas (yarn tasks run build,typecheck -A).

Output modes: interlaced (default), --buffered, --silent-dependencies, --errors-only (only print the logs of failed tasks), and --json.

By default the tasks run through the background daemon; on CI (when the CI environment variable is set) they run in an in-process daemon instead (--standalone), which can be toggled with --standalone/--no-standalone. Runs started from within a task always reuse the daemon running it.

#--all, -Aboolean

Run the task in every workspace declaring it

#--fromboolean

Run the task in the workspaces matching these patterns

#--sincestring

Run the task in the 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

Follow dependencies, or dependents when combined with --since

#--follow-dependenciesboolean

Also run the task in the dependencies of the selected workspaces

#--follow-dependentsboolean

Also run the task in the dependents of the selected workspaces

#--followed-dependenciesboolean

Dependency kinds followed by --follow-dependencies and --follow-dependents

#--includeboolean

Only keep workspaces matching these patterns

#--excludeboolean

Skip workspaces matching these patterns

#--privateboolean

Include private workspaces

#--onlyboolean

Skip cross-workspace task dependencies outside of the selection

#--continueboolean

Keep running independent tasks after a failure

#--bufferedboolean

Print the output of each task once it completes

#--silent-dependenciesboolean

Only print the output of the target tasks

#--errors-onlyboolean

Only print the output of the tasks that failed

#--timestampsboolean

Prefix each output line with a timestamp

#--jsonboolean

Output JSON objects (one per line) for each task event

#--verbose, -vboolean

Increase the verbosity level (can be repeated)

#--standaloneboolean

Run the tasks in an in-process daemon rather than the background one