{"record":{"id":"762e315456533df4","repo":"cypress-io/cypress","slug":"projects-in-angular-json-is-not-defined","errorCode":null,"errorMessage":"projects in angular.json is not defined","messagePattern":"projects in angular\\.json is not defined","errorType":"exception","errorClass":"SchematicsException","httpStatus":null,"severity":"error","filePath":"npm/cypress-schematic/src/schematics/ng-add/index.ts","lineNumber":229,"sourceCode":"  if (component) {\n    projectArchitectJson['ct'] = componentJson\n  }\n\n  if (e2e || !projectArchitectJson['e2e']) {\n    projectArchitectJson['e2e'] = e2eJson\n  }\n\n  return tree.overwrite('./angular.json', JSON.stringify(angularJsonVal, null, 2))\n}\n\nfunction modifyAngularJson (options: any): Rule {\n  return (tree: Tree, context: SchematicContext) => {\n    if (tree.exists('./angular.json')) {\n      const angularJsonVal = getAngularJsonValue(tree)\n      const { projects } = angularJsonVal\n\n      if (!projects) {\n        throw new SchematicsException('projects in angular.json is not defined')\n      }\n\n      Object.keys(projects).forEach((project) => {\n        const builder = '@cypress/schematic:cypress'\n        const runJson = {\n          builder,\n          options: {\n            devServerTarget: `${project}:serve`,\n          },\n          configurations: {\n            production: {\n              devServerTarget: `${project}:serve:production`,\n            },\n          },\n        }\n\n        const openJson = {\n          builder,","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/cypress-io/cypress/blob/0d85fdc91230885bca0a91df278312800a48b727/npm/cypress-schematic/src/schematics/ng-add/index.ts#L211-L247","documentation":"Raised by modifyAngularJson() during `ng add @cypress/schematic` when angular.json exists and was parsed, but its top-level `projects` key is missing or falsy. The schematic iterates Object.keys(projects) to add cypress-run/cypress-open (and optionally e2e/ct) targets per project, so without that key it cannot proceed and aborts with a SchematicsException.","triggerScenarios":"Running `ng add @cypress/schematic` in a workspace whose angular.json has no `projects` field — e.g. a hand-edited or partially generated angular.json, a non-Angular workspace with a stray angular.json, or a malformed JSON where projects was deleted.","commonSituations":"A workspace not created with `ng new`; manual edits that removed projects; an Angular CLI version that wrote an unexpected angular.json shape; a monorepo where the real Angular workspace lives in a subdirectory.","solutions":["Open angular.json and ensure it has a top-level `projects` object listing at least one project (the standard Angular CLI shape).","If the workspace is not a real Angular CLI workspace, create one with `ng new` or run the schematic from the directory that actually holds angular.json.","Run `ng add @cypress/schematic` from the project root where the well-formed angular.json lives.","Validate angular.json with `ng config` or by running any standard `ng generate` command to confirm Angular accepts it."],"exampleFix":"// before: angular.json has no \"projects\" key\n// after:\n{\n  \"$schema\": \"./node_modules/@angular/cli/lib/config/schema.json\",\n  \"version\": 1,\n  \"newProjectRoot\": \"projects\",\n  \"projects\": {\n    \"app\": { /* ... */ }\n  }\n}","handlingStrategy":"validation","validationCode":"import { getAngularJsonValue } from '../../utils'\n\nfunction assertHasProjects(tree: Tree) {\n  const { projects } = getAngularJsonValue(tree)\n  if (!projects) {\n    throw new Error('angular.json is missing a top-level \"projects\" object')\n  }\n  return projects\n}","typeGuard":"function hasProjects(json: any): json is { projects: Record<string, unknown> } {\n  return Boolean(json && typeof json === 'object' && json.projects && typeof json.projects === 'object')\n}","tryCatchPattern":null,"preventionTips":["Ensure angular.json conforms to the Angular CLI schema (with a projects object) before running ng add.","Run `ng config` to validate the workspace.","Create workspaces with `ng new` to guarantee the correct shape."],"tags":["angular","schematic","ng-add","angular-json"],"backgroundTag":null,"analyzedSha":"0d85fdc91230885bca0a91df278312800a48b727","analyzedAt":"2026-08-12T16:24:28.056Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}