yarn tasks run — Yarn CLI reference
Run a task
yarn tasks run
Run a task
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,--allruns 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 fromYARN_CHANGESET_BASE/YARN_CHANGESET_HEAD(orTURBO_SCM_BASE/TURBO_SCM_HEAD). -
--follow-dependenciesadds the transitive workspace dependencies of the selection, and--follow-dependentsadds its dependents. When both are set, dependencies are followed from the dependents too (pnpm’s--filter '...{pkg}...').--recursivefollows dependents when combined with--since(so--since --recursiveselects all the affected workspaces), and dependencies otherwise.--followed-dependenciesrestricts the traversal toprodordevdependencies. Without-A/--from/--since, they apply to the current workspace. -
--include/--exclude <glob>and--no-privatefilter 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).
A @long-lived task is a single instance shared by the project. Running it attaches to that instance when there is one, and a task depending on it uses the instance already running or starts it; either way it keeps running in the background after the run ends or is interrupted, until yarn tasks stop. Standalone runs stop it when they exit.
Output modes: interlaced (default), --buffered, --silent-dependencies, --errors-only (only print the logs of failed tasks), and --json. When tasks fail, the run ends with a summary of the ones that failed and of the ones that were cancelled because of it (--json reports them as events).
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.
A run uses the taskfiles as they are when it starts. Editing them later doesn’t affect the tasks already scheduled or running, even when they are removed from their taskfile: long-lived tasks keep running until stopped with yarn tasks stop.
Run the task in every workspace declaring it
Run the task in the workspaces matching these patterns
Run the task in the workspaces changed since a ref, or since the configured base refs when no ref is provided
Compare against this ref rather than the working tree when used with --since
Follow dependencies, or dependents when combined with --since
Also run the task in the dependencies of the selected workspaces
Also run the task in the dependents of the selected workspaces
Dependency kinds followed by --follow-dependencies and --follow-dependents
Only keep workspaces matching these patterns
Skip workspaces matching these patterns
Include private workspaces
Skip cross-workspace task dependencies outside of the selection
Keep running independent tasks after a failure
Print the output of each task once it completes
Only print the output of the target tasks
Only print the output of the tasks that failed
Prefix each output line with a timestamp
Output JSON objects (one per line) for each task event
Increase the verbosity level (can be repeated)
Run the tasks in an in-process daemon rather than the background one
Examples#
Run the build task of the current workspace (and its dependencies)
Run the test task, forwarding extra arguments to it
Run the build task in all workspaces declaring it
Run the build task in the workspaces affected by the changes since the base refs