{"record":{"id":"6271123dccb1b30c","repo":"angular/angular-cli","slug":"project-projectname-does-not-exist","errorCode":null,"errorMessage":"Project \"${projectName}\" does not exist.","messagePattern":"Project \"(.+?)\" does not exist\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/schematics/angular/utility/workspace.ts","lineNumber":130,"sourceCode":"}\n\n/**\n * Build a default project path for generating.\n * @param project The project which will have its default path generated.\n */\nexport function buildDefaultPath(project: workspaces.ProjectDefinition): string {\n  const root = project.sourceRoot ? `/${project.sourceRoot}/` : `/${project.root}/src/`;\n  const projectDirName =\n    project.extensions['projectType'] === ProjectType.Application ? 'app' : 'lib';\n\n  return `${root}${projectDirName}`;\n}\n\nexport async function createDefaultPath(tree: Tree, projectName: string): Promise<string> {\n  const workspace = await getWorkspace(tree);\n  const project = workspace.projects.get(projectName);\n  if (!project) {\n    throw new Error(`Project \"${projectName}\" does not exist.`);\n  }\n\n  return buildDefaultPath(project);\n}\n\nexport function* allWorkspaceTargets(\n  workspace: workspaces.WorkspaceDefinition,\n): Iterable<[string, workspaces.TargetDefinition, string, workspaces.ProjectDefinition]> {\n  for (const [projectName, project] of workspace.projects) {\n    for (const [targetName, target] of project.targets) {\n      yield [targetName, target, projectName, project];\n    }\n  }\n}\n\nexport function* allTargetOptions(\n  target: workspaces.TargetDefinition,\n  skipBaseOptions = false,","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/schematics/angular/utility/workspace.ts#L112-L148","documentation":"createDefaultPath looks up the given project in the workspace definition (angular.json) to compute its default source path. If the workspace has no project with that name, it throws this plain Error. The schematics (module, pipe, generateFromFiles) call it to determine where to place generated files.","triggerScenarios":"Calling `ng generate module|pipe` with --project=<name> (or having a default project) where <name> is not a key under \"projects\" in angular.json/workspace config.","commonSituations":"Typo in the project name, running the schematic in a repo whose angular.json was renamed/removed, working in a subfolder of an Nx/monorepo where the CLI cannot find the workspace, or referencing a library deleted from angular.json.","solutions":["Run `ng generate module my-module --project=<exact-name>` using a name listed under \"projects\" in angular.json (`ng config projects` or open the file to check).","Fix the defaultProject / workspace context: run the command from the repository root that contains angular.json.","Add the missing project to angular.json if it should exist (or restore a deleted project block).","Omit --project so the CLI uses the single/default project when only one exists."],"exampleFix":"// before\nng generate module shared --project=shard-lib\n// after\nng generate module shared --project=shared-lib","handlingStrategy":"validation","validationCode":"import { workspaces } from '@angular-devkit/core';\nimport * as fs from 'fs';\nconst cfg = JSON.parse(fs.readFileSync('angular.json', 'utf8'));\nif (!cfg.projects?.[projectName]) {\n  throw new Error(`Project \"${projectName}\" not found. Available: ${Object.keys(cfg.projects).join(', ')}`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await ngGenerate(['module', 'shared', '--project', name]);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('does not exist')) {\n    console.error(`Unknown project \"${name}\"; check angular.json projects key.`);\n  } else throw e;\n}","preventionTips":["Verify the project key with `ng config projects` or by opening angular.json before passing --project.","Run ng commands from the directory containing angular.json so the right workspace loads.","In monorepos, script project name completion (list from angular.json) to avoid typos."],"tags":["schematics","workspace","configuration"],"backgroundTag":"project-not-found-in-workspace","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}