yarn run — Yarn CLI reference

Run a dependency binary or local script

Docs/Reference/CLI/run

yarn run

Run a dependency binary or local script

yarn run <NAME> <ARGS…>

This command runs a tool selected from the current workspace:

  • If the local package.json scripts field contains a matching script name, Yarn executes that script.

  • Otherwise, if a taskfile exists in the workspace and contains a task with the matching name, Yarn runs that task (including all its dependencies in the correct order).

  • Otherwise, if one of the local workspace’s dependencies exposes a binary with a matching name, Yarn runs that binary.

  • Otherwise, if the specified name contains a colon character and if one of the workspaces in the project contains exactly one script with a matching name, Yarn runs that script.

Script commands run from the workspace that declares them. Dependency binaries run from the current working directory unless --run-cwd is set.

#--top-level, -Tboolean

Resolve scripts and binaries from the top-level workspace

#--binaries-only, -Bboolean

Only consider dependency binaries, not package scripts or tasks

#--error-if-missingboolean

Return an error when the script, task, or binary cannot be found

#--run-cwdboolean

Directory from which to run the selected script or binary

#--inspectstring

Forward --inspect to Node.js when executing a Node binary

#--inspect-brkstring

Forward --inspect-brk to Node.js when executing a Node binary

#--inspect-waitstring

Forward --inspect-wait to Node.js when executing a Node binary

#--requireboolean

Preload a module through Node.js --require when executing a Node binary