{"record":{"id":"a081fc35d8cf5f28","repo":"angular/angular-cli","slug":"cannot-determine-project-for-command-this-is-a-mu","errorCode":null,"errorMessage":"Cannot determine project for command.\nThis is a multi-project workspace and more than one project supports this command. Run \"ng ${this.command}\" to execute the command for a specific project or change the current working directory to a project directory.\n\nAvailable projects are:\n${allProjectsForTargetName\n              .sort()\n              .map((p) => `- ${p}`)\n              .join('\\n')}","messagePattern":"Cannot determine project for command\\.\nThis is a multi-project workspace and more than one project supports this command\\. Run \"ng (.+?)\" to execute the command for a specific project or change the current working directory to a project directory\\.\n\nAvailable projects are:\n(.+?)`\\)\n              \\.join\\('\\\\n'\\)\\}","errorType":"exception","errorClass":"CommandModuleError","httpStatus":null,"severity":"error","filePath":"packages/angular/cli/src/command-builder/architect-command-module.ts","lineNumber":187,"sourceCode":"    }\n\n    if (this.multiTarget) {\n      // For multi target commands, we always list all projects that have the target.\n      return allProjectsForTargetName;\n    } else {\n      if (allProjectsForTargetName.length === 1) {\n        return allProjectsForTargetName;\n      }\n\n      const maybeProject = getProjectByCwd(workspace);\n      if (maybeProject) {\n        return allProjectsForTargetName.includes(maybeProject) ? [maybeProject] : undefined;\n      }\n\n      const { getYargsCompletions, help } = this.context.args.options;\n      if (!getYargsCompletions && !help) {\n        // Only issue the below error when not in help / completion mode.\n        throw new CommandModuleError(\n          'Cannot determine project for command.\\n' +\n            'This is a multi-project workspace and more than one project supports this command. ' +\n            `Run \"ng ${this.command}\" to execute the command for a specific project or change the current ` +\n            'working directory to a project directory.\\n\\n' +\n            `Available projects are:\\n${allProjectsForTargetName\n              .sort()\n              .map((p) => `- ${p}`)\n              .join('\\n')}`,\n        );\n      }\n    }\n\n    return undefined;\n  }\n\n  /** @returns a sorted list of project names to be used for auto completion. */\n  private getProjectChoices(): string[] | undefined {\n    const { workspace } = this.context;","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular/cli/src/command-builder/architect-command-module.ts#L169-L205","documentation":"Commands that operate on an architect target (like ng build/serve/test) need to know which project to run against. In a multi-project workspace where more than one project defines the requested target, the CLI cannot pick one and throws this error listing the candidate projects.","triggerScenarios":"Running e.g. 'ng build' (no project argument) in a workspace with several projects that each have a 'build' target, and the current directory is the workspace root, not inside a specific project.","commonSituations":"Nx/npm-style monorepos with apps/lib1/lib2; running commands from the repo root in CI scripts; after adding a second app to an angular.json that previously had one.","solutions":["Pass the project explicitly: 'ng build my-app'","Change the working directory into the specific project folder that has its own angular.json","Use a defaultProject/configured project in angular.json or an npm script per project","In CI, parameterize the project name instead of relying on cwd inference"],"exampleFix":"// before\ning build\n// after\ncd projects/admin && ng build  # or: ng build admin","handlingStrategy":"validation","validationCode":"import { workspaces } from '@angular-devkit/core';\n// or simply:\nconst count = getProjectsInAngularJson().filter(p => hasTarget(p, 'build')).length;\nif (count > 1) {\n  args.push('--project', process.env.PROJECT ?? count && 'specify-a-project');\n}","typeGuard":null,"tryCatchPattern":"try {\n  execSync('ng build', { stdio: 'inherit' });\n} catch (e) {\n  if (String(e).includes('Cannot determine project')) {\n    const projects = String(e).match(/- (.+)/g) ?? [];\n    throw new Error(`Pass --project; candidates: ${projects.join(', ')}`);\n  }\n  throw e;\n}","preventionTips":["Always pass --project in multi-project workspaces and CI","Run commands from within a single project directory when relying on inference","Keep one 'defaultProject'/'cli.defaultProjectName' configured","Script per-app commands (npm run build:admin) instead of bare ng build"],"tags":["angular-cli","multi-project","workspace","architect"],"backgroundTag":"ambiguous-project-target","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}