{"record":{"id":"e329c95a80901629","repo":"yarnpkg/yarn","slug":"workspacemissingworkspace","errorCode":null,"errorMessage":"workspaceMissingWorkspace","messagePattern":"workspaceMissingWorkspace","errorType":"exception","errorClass":"MessageError","httpStatus":null,"severity":"error","filePath":"src/cli/commands/workspace.js","lineNumber":25,"sourceCode":"import {NODE_BIN_PATH, YARN_BIN_PATH} from '../../constants';\n\nconst invariant = require('invariant');\n\nexport 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","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/yarnpkg/yarn/blob/c2dda503f3759b5be5f0e24ecd9cf5c97a540147/src/cli/commands/workspace.js#L7-L43","documentation":"Thrown by 'yarn workspace' when fewer than one positional argument is supplied. The command form is 'yarn workspace <workspace-name> <command> [args...]'; omitting the workspace name is rejected before any resolution.","triggerScenarios":"Running bare 'yarn workspace' (no further args), so args.length < 1.","commonSituations":"User forgot the workspace name; confusion with 'yarn workspaces' (plural) which has different subcommands.","solutions":["Supply both a workspace name and a command: 'yarn workspace <name> <command>'.","List available workspaces first with 'yarn workspaces info' to get the exact name."],"exampleFix":"# before\n$ yarn workspace\n# after\n$ yarn workspace my-app build","handlingStrategy":"validation","validationCode":"if (args.length < 1) {\n  throw new Error(\"'yarn workspace' requires a workspace name and a command: yarn workspace <name> <command>\");\n}","typeGuard":"function hasWorkspaceArgs(args: string[]): boolean {\n  return Array.isArray(args) && args.length >= 2;\n}","tryCatchPattern":null,"preventionTips":["Remember the form 'yarn workspace <name> <command>' (singular).","Use 'yarn workspaces info' to discover valid names first."],"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"}