{"record":{"id":"8f71fca9f39eca31","repo":"cypress-io/cypress","slug":"could-not-find-a-project-with-projecttype-applica","errorCode":null,"errorMessage":"Could not find a project with projectType \"application\" in \"angular.json\". Visit https://on.cypress.io/configuration to see how to pass in a custom project configuration","messagePattern":"Could not find a project with projectType \"application\" in \"angular\\.json\"\\. Visit https://on\\.cypress\\.io/configuration to see how to pass in a custom project configuration","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"npm/webpack-dev-server/src/helpers/angularHandler.ts","lineNumber":49,"sourceCode":"}\n\ntype AngularJson = {\n  defaultProject?: string\n  projects: {\n    [project: string]: AngularJsonProjectConfig\n  }\n}\n\nexport async function getProjectConfig (projectRoot: string): Promise<Cypress.AngularDevServerProjectConfig> {\n  const angularJson = await getAngularJson(projectRoot)\n\n  let { defaultProject } = angularJson\n\n  if (!defaultProject) {\n    defaultProject = Object.keys(angularJson.projects).find((name) => angularJson.projects[name].projectType === 'application')\n\n    if (!defaultProject) {\n      throw new Error('Could not find a project with projectType \"application\" in \"angular.json\". Visit https://on.cypress.io/configuration to see how to pass in a custom project configuration')\n    }\n  }\n\n  const defaultProjectConfig = angularJson.projects[defaultProject]\n\n  const { architect, root, sourceRoot } = defaultProjectConfig\n  const { build } = architect\n\n  return {\n    root,\n    sourceRoot,\n    buildOptions: {\n      ...build.options,\n      ...build.configurations?.development || {},\n    },\n  }\n}\n","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/cypress-io/cypress/blob/0d85fdc91230885bca0a91df278312800a48b727/npm/webpack-dev-server/src/helpers/angularHandler.ts#L31-L67","documentation":"Thrown by getProjectConfig when Cypress component testing for Angular cannot pick a default project from angular.json. The code first reads angularJson.defaultProject; if that is unset it falls back to scanning angularJson.projects for the first entry whose projectType is 'application', and only throws when that scan also comes up empty. The message points users at the Cypress configuration docs so they can pass a custom project config explicitly.","triggerScenarios":"Calling the Angular webpack-dev-server handler on a workspace whose angular.json has no top-level \"defaultProject\" key and where every project under \"projects\" has projectType other than \"application\" (e.g. only \"library\" projects). Reproducible by scaffolding @cypress/webpack-dev-server with the Angular framework in an Nx monorepo where the Cypress-targeted app lives under a non-standard projectType.","commonSituations":"Multi-project Angular/Nx workspaces, library-only packages, angular.json that was hand-edited and lost its defaultProject field, or an Angular CLI workspace where the application was generated after the libraries and defaultProject was never set. Also seen after migrating from Nx older formats that drop defaultProject.","solutions":["Add \"defaultProject\": \"<your-app-name>\" to the root of angular.json so Cypress knows which project to build.","Ensure at least one project under angular.json \"projects\" has \"projectType\": \"application\" (regenerate via `ng generate application` if missing).","Pass an explicit project config to Cypress via the devServer options (see https://on.cypress.io/configuration) so Cypress does not have to infer it.","If using Nx, set defaultProject in nx.json as well and verify the Cypress devServer config targets the correct project."],"exampleFix":"// before (angular.json)\n{\n  \"projects\": {\n    \"ui-lib\": { \"projectType\": \"library\" }\n  }\n}\n// after\n{\n  \"defaultProject\": \"my-app\",\n  \"projects\": {\n    \"my-app\": { \"projectType\": \"application\", \"architect\": { ... } },\n    \"ui-lib\": { \"projectType\": \"library\" }\n  }\n}","handlingStrategy":"validation","validationCode":"// Run before starting the Cypress Angular dev server\nimport { readFileSync } from 'fs'\nimport { resolve } from 'path'\n\nfunction validateAngularProject (projectRoot: string) {\n  const json = JSON.parse(readFileSync(resolve(projectRoot, 'angular.json'), 'utf8'))\n  const hasDefault = Boolean(json.defaultProject)\n  const hasApp = Object.values(json.projects || {}).some(\n    (p: any) => p?.projectType === 'application',\n  )\n  if (!hasDefault && !hasApp) {\n    throw new Error('angular.json needs defaultProject or an application projectType')\n  }\n}","typeGuard":"function hasAngularApplication (json: any): json is { defaultProject: string } | { projects: Record<string, { projectType: 'application' }> } {\n  return Boolean(json?.defaultProject) ||\n    Object.values(json?.projects ?? {}).some((p: any) => p?.projectType === 'application')\n}","tryCatchPattern":null,"preventionTips":["Always set defaultProject in angular.json for Angular Cypress projects.","Validate angular.json shape in a pretest npm script before running cypress.","For Nx workspaces, double-check defaultProject in nx.json as well."],"tags":["angular","component-testing","configuration","dev-server"],"backgroundTag":null,"analyzedSha":"0d85fdc91230885bca0a91df278312800a48b727","analyzedAt":"2026-08-12T16:24:28.056Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}