cypress-io/cypress · error · Error
Could not find a project with projectType "application" in "
Error message
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
What it means
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.
Source
Thrown at npm/webpack-dev-server/src/helpers/angularHandler.ts:49
}
type AngularJson = {
defaultProject?: string
projects: {
[project: string]: AngularJsonProjectConfig
}
}
export async function getProjectConfig (projectRoot: string): Promise<Cypress.AngularDevServerProjectConfig> {
const angularJson = await getAngularJson(projectRoot)
let { defaultProject } = angularJson
if (!defaultProject) {
defaultProject = Object.keys(angularJson.projects).find((name) => angularJson.projects[name].projectType === 'application')
if (!defaultProject) {
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')
}
}
const defaultProjectConfig = angularJson.projects[defaultProject]
const { architect, root, sourceRoot } = defaultProjectConfig
const { build } = architect
return {
root,
sourceRoot,
buildOptions: {
...build.options,
...build.configurations?.development || {},
},
}
}
View on GitHub (pinned to 0d85fdc912)
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.
Example fix
// before (angular.json)
{
"projects": {
"ui-lib": { "projectType": "library" }
}
}
// after
{
"defaultProject": "my-app",
"projects": {
"my-app": { "projectType": "application", "architect": { ... } },
"ui-lib": { "projectType": "library" }
}
} Defensive patterns
Strategy: validation
Validate before calling
// Run before starting the Cypress Angular dev server
import { readFileSync } from 'fs'
import { resolve } from 'path'
function validateAngularProject (projectRoot: string) {
const json = JSON.parse(readFileSync(resolve(projectRoot, 'angular.json'), 'utf8'))
const hasDefault = Boolean(json.defaultProject)
const hasApp = Object.values(json.projects || {}).some(
(p: any) => p?.projectType === 'application',
)
if (!hasDefault && !hasApp) {
throw new Error('angular.json needs defaultProject or an application projectType')
}
} Type guard
function hasAngularApplication (json: any): json is { defaultProject: string } | { projects: Record<string, { projectType: 'application' }> } {
return Boolean(json?.defaultProject) ||
Object.values(json?.projects ?? {}).some((p: any) => p?.projectType === 'application')
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Could not find angular.json. Looked in ${projectRoot} and up
- Your Cypress devServer config is missing a required webpackC
- Could not compile application files
- Could not resolve "${dep}". Do you have "@angular-devkit/bui
- Cypress cannot compile your Next.js application when "nodeVe
AI-assisted analysis of cypress-io/cypress@0d85fdc912 (2026-08-12).
Data as JSON: /api/errors/8f71fca9f39eca31.
Report an issue: GitHub.