{"record":{"id":"1db62fca9aa002bb","repo":"yarnpkg/yarn","slug":"workspacemissingcommand","errorCode":null,"errorMessage":"workspaceMissingCommand","messagePattern":"workspaceMissingCommand","errorType":"exception","errorClass":"MessageError","httpStatus":null,"severity":"error","filePath":"src/cli/commands/workspace.js","lineNumber":29,"sourceCode":"export function setFlags(commander: Object) {}\n\nexport function hasWrapper(commander: Object, args: Array<string>): boolean {\n  return true;\n}\n\nexport async function run(config: Config, reporter: Reporter, flags: Object, args: Array<string>): Promise<void> {\n  const {workspaceRootFolder} = config;\n\n  if (!workspaceRootFolder) {\n    throw new MessageError(reporter.lang('workspaceRootNotFound', config.cwd));\n  }\n\n  if (args.length < 1) {\n    throw new MessageError(reporter.lang('workspaceMissingWorkspace'));\n  }\n\n  if (args.length < 2) {\n    throw new MessageError(reporter.lang('workspaceMissingCommand'));\n  }\n\n  const manifest = await config.findManifest(workspaceRootFolder, false);\n  invariant(manifest && manifest.workspaces, 'We must find a manifest with a \"workspaces\" property');\n\n  const workspaces = await config.resolveWorkspaces(workspaceRootFolder, manifest);\n  const [workspaceName, ...rest] = args || [];\n\n  if (!Object.prototype.hasOwnProperty.call(workspaces, workspaceName)) {\n    throw new MessageError(reporter.lang('workspaceUnknownWorkspace', workspaceName));\n  }\n\n  const workspace = workspaces[workspaceName];\n\n  try {\n    await child.spawn(NODE_BIN_PATH, [YARN_BIN_PATH, ...rest], {\n      stdio: 'inherit',\n      cwd: workspace.loc,","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/yarnpkg/yarn/blob/c2dda503f3759b5be5f0e24ecd9cf5c97a540147/src/cli/commands/workspace.js#L11-L47","documentation":"Thrown by 'yarn workspace' when a workspace name is given but no command follows (fewer than 2 positional args). The command requires something to actually run inside the workspace.","triggerScenarios":"Running 'yarn workspace my-app' with no command, so args.length < 2.","commonSituations":"User stopped at the workspace name; intended 'yarn workspace run <script>' but Yarn's workspace command takes the command directly.","solutions":["Append the command to run: 'yarn workspace <name> <command> [args...]'.","For a package script use 'yarn workspace <name> run <script>'."],"exampleFix":"# before\n$ yarn workspace my-app\n# after\n$ yarn workspace my-app build","handlingStrategy":"validation","validationCode":"if (args.length < 2) {\n  throw new Error(\"'yarn workspace' requires a command to run: yarn workspace <name> <command> [args...]\");\n}","typeGuard":"function hasWorkspaceCommand(args: string[]): boolean {\n  return Array.isArray(args) && args.length >= 2;\n}","tryCatchPattern":null,"preventionTips":["Always include the trailing command (e.g. 'build', 'run <script>').","Document example invocations in the monorepo README."],"tags":["cli-args","workspaces","validation"],"backgroundTag":null,"analyzedSha":"c2dda503f3759b5be5f0e24ecd9cf5c97a540147","analyzedAt":"2026-08-13T04:17:06.305Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}