{"record":{"id":"d0cb273b2e6ff454","repo":"cypress-io/cypress","slug":"could-not-compile-application-files","errorCode":null,"errorMessage":"Could not compile application files","messagePattern":"Could not compile application files","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"npm/cypress-schematic/src/builders/cypress/index.ts","lineNumber":127,"sourceCode":"    switchMap((builderName) => {\n      let overrides = {}\n\n      // @NOTE: Do not forward watch option if not supported by the target dev server,\n      // this is relevant for running Cypress against dev server target that does not support this option,\n      // for instance @nguniversal/builders:ssr-dev-server.\n      // see https://github.com/nrwl/nx/blob/f930117ed6ab13dccc40725c7e9551be081cc83d/packages/cypress/src/executors/cypress/cypress.impl.ts\n      if (builderName !== '@nguniversal/builders:ssr-dev-server') {\n        // eslint-disable-next-line no-console\n        console.info(`Passing watch mode to DevServer - watch mode is ${watch}`)\n        overrides = {\n          watch,\n        }\n      }\n\n      return scheduleTargetAndForget(context, targetFromTargetString(devServerTarget), overrides).pipe(\n        map((output: any) => {\n          if (!output.success && !watch) {\n            throw new Error('Could not compile application files')\n          }\n\n          return output.baseUrl as string\n        }),\n      )\n    }),\n  )\n}\n\nexport default createBuilder<CypressBuilderOptions>(runCypress)\n","sourceCodeStart":109,"sourceCodeEnd":138,"githubUrl":"https://github.com/cypress-io/cypress/blob/0d85fdc91230885bca0a91df278312800a48b727/npm/cypress-schematic/src/builders/cypress/index.ts#L109-L138","documentation":"Raised by startDevServer() in the @cypress/schematic Angular builder when the scheduled dev-server target returns output.success === false in non-watch mode. The builder delegates app compilation to the Angular dev-server target (referenced by devServerTarget, e.g. project:serve); when that build fails, Cypress has no baseUrl to test against, so the builder aborts with this generic message rather than running tests against a broken app.","triggerScenarios":"Running `ng run <project>:cypress` (or cypress-run) where the devServerTarget's serve build emits TypeScript/Angular compile errors and watch is false (single run). The thrown error masks the underlying Angular compiler diagnostics, which are printed above it in the builder log.","commonSituations":"A TypeScript or template compile error in the Angular app; a missing or misnamed devServerTarget in angular.json; Angular CLI version mismatch; an AOT production build failure only triggered in CI; the dev server target name changed after a refactor.","solutions":["Read the builder output ABOVE this error — the real Angular compiler errors are logged there. Fix the reported TS/template errors first.","Run the dev server target directly (e.g. `ng serve` or `ng run <project>:serve`) in isolation to reproduce and fix compile failures.","Confirm devServerTarget in angular.json points at an existing serve target for the right project.","Match Angular CLI / devkit versions across the workspace; reinstall dependencies."],"exampleFix":"// before: devServerTarget points at a serve target that fails to compile\n// after:\n// 1. run `ng run app:serve` and fix TS/template errors\n// 2. then re-run `ng run app:cypress`","handlingStrategy":"try-catch","validationCode":"// Validate the devServerTarget builds before wiring it to the Cypress builder:\n// run `ng run <project>:serve` (or the configured target) and exit non-zero on failure\n// before scheduling cypress.","typeGuard":null,"tryCatchPattern":"// In a wrapper script around `ng run app:cypress`:\ntry {\n  await exec('ng run app:cypress')\n} catch (e) {\n  if (/Could not compile application files/.test(String(e))) {\n    // the real compiler errors are above; re-run `ng run app:serve` to surface them\n    await exec('ng run app:serve')\n  }\n  throw e\n}","preventionTips":["Keep the Angular app compiling green with `ng build` before adding Cypress to the pipeline.","Pin Angular CLI/devkit versions across the workspace.","Read the full builder log — the real diagnostics are printed above this generic message."],"tags":["angular","builder","dev-server","compile"],"backgroundTag":null,"analyzedSha":"0d85fdc91230885bca0a91df278312800a48b727","analyzedAt":"2026-08-12T16:24:28.056Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}