Yarn Berry "yarn workspaces focus" missing plugin in CI
yarn workspaces focus installs only one workspace and its dependencies, which speeds up CI for a single package. It lives in the workspace-tools plugin; without that plugin, Yarn does not know the command.
What this error means
A CI step running yarn workspaces focus <pkg> fails with "Usage Error: Couldn't find the workspaces focus command" or an unknown-command error.
yarn
Usage Error: Couldn't find a script named "focus".
$ yarn workspaces focus @acme/api --productionCommon causes
The workspace-tools plugin is not installed
workspaces focus is not built in; the @yarnpkg/plugin-workspace-tools plugin must be imported to add it.
The plugin was added locally but not committed
The plugin lives in .yarn/plugins and its reference in .yarnrc.yml; if not committed, CI lacks it.
How to fix it
Add and commit the workspace-tools plugin
- Run
yarn plugin import workspace-tools. - Commit
.yarn/pluginsand the updated.yarnrc.yml. - CI can then run
yarn workspaces focus.
Terminal
yarn plugin import workspace-tools
git add .yarn/plugins .yarnrc.ymlFocus a single workspace in CI
Once the plugin is present, install just the target workspace and its production deps to cut install time.
.github/workflows/ci.yml
- run: yarn workspaces focus @acme/api --productionHow to prevent it
- Commit
.yarn/pluginsand.yarnrc.ymlso plugins are available in CI. - Import
workspace-toolsbefore relying onworkspaces focus. - Use
focusto install only what a job needs.
Related guides
Yarn Berry ".yarnrc.yml" settings not applied in CIFix Yarn Berry cases where .yarnrc.yml settings (nodeLinker, yarnPath) are ignored in CI - usually Yarn class…
Yarn Berry PnP "Cannot find module" (require stack) in CIFix Yarn Berry Plug'n'Play "Cannot find module X" in CI - a tool that does not understand PnP resolution fail…
Yarn classic "Couldn't find package X required by Y" workspace in CIFix Yarn 1 "Couldn't find package X required by Y on the npm registry" in CI - a workspace dependency is not…