cypress-io/cypress · error · Error

Could not find angular.json. Looked in ${projectRoot} and up

Error message

Could not find angular.json. Looked in ${projectRoot} and up.

What it means

Thrown by getAngularJson after find-up walks the directory tree starting at projectRoot and fails to locate a file named angular.json. The lookup uses tsImport('find-up') because find-up 6+ is ESM-only and this package is CJS. This is a project-detection error: Cypress believes it is in an Angular project (e.g. because the Angular framework handler was selected) but cannot find the manifest that defines the project.

Source

Thrown at npm/webpack-dev-server/src/helpers/angularHandler.ts:226

    generateBrowserWebpackConfigFromContext,
    getCommonConfig,
    getStylesConfig,
    logging,
  }
}

export async function getAngularJson (projectRoot: string): Promise<AngularJson> {
  // NOTE: @cypress/webpack-dev-server is a CJS package, but find-up +6.0.0 is an ESM only package.
  // In order to dynamically import the find-up package, we need to use tsx to do so until @cypress/webpack-dev-server is an ESM-only package,
  // which would be a breaking change to @cypress/webpack-dev-server and cypress.
  const { tsImport } = require('tsx/esm/api')

  const { findUp } = await tsImport('find-up', __filename) as typeof import('find-up')

  const angularJsonPath = await findUp('angular.json', { cwd: projectRoot })

  if (!angularJsonPath) {
    throw new Error(`Could not find angular.json. Looked in ${projectRoot} and up.`)
  }

  const angularJson = await fs.readFile(angularJsonPath, 'utf8')

  return JSON.parse(angularJson)
}

function createFakeContext (projectRoot: string, defaultProjectConfig: Cypress.AngularDevServerProjectConfig, logging: typeof AngularLogging) {
  const logger = new logging.Logger(debugPrefix)

  // Proxy all logging calls through to the debug logger
  logger.forEach((value: AngularLogging.LogEntry) => {
    debug(JSON.stringify(value))
  })

  const context = {
    target: {
      project: 'angular',

View on GitHub (pinned to 0d85fdc912)

Solutions

  1. Confirm angular.json exists at the Angular workspace root and run `cypress open`/`cypress run` from that root.
  2. Set the correct projectRoot / componentFolder in cypress.config.ts so it resolves up to the directory containing angular.json.
  3. If using Nx with angular.json renamed or relocated, regenerate it (`ng update` or restore the workspace.json -> angular.json mapping).
  4. Switch the devServer framework away from Angular if you are not actually testing an Angular app.

Example fix

// before (cypress.config.ts)
export default defineConfig({
  component: {
    devServer: { framework: 'angular' },
    componentFolder: './libs/some-lib',
  },
})
// after
export default defineConfig({
  component: {
    devServer: { framework: 'angular' },
    componentFolder: './apps/my-app/src/app',
    // projectRoot should resolve upward to the folder containing angular.json
  },
})
Defensive patterns

Strategy: validation

Validate before calling

import { existsSync } from 'fs'
import { resolve } from 'path'

function findAngularJsonUp (dir: string): string | null {
  let cur = dir
  for (let i = 0; i < 10 && cur !== '/'; i++) {
    if (existsSync(resolve(cur, 'angular.json'))) return resolve(cur, 'angular.json')
    cur = resolve(cur, '..')
  }
  return null
}

Type guard

function hasAngularJsonInTree (projectRoot: string): boolean {
  return findAngularJsonUp(projectRoot) !== null
}

Prevention

When it happens

Trigger: Invoking the Angular webpack-dev-server handler with a projectRoot that points at a sub-directory of an Angular workspace (e.g. a project that lives under apps/my-app) where angular.json sits several levels above and find-up's recursion was constrained, or invoking the Angular handler on a non-Angular project.

Common situations: Wrong `componentFolder` / projectRoot configured in cypress.config.ts, running Cypress from a deeply nested package whose angular.json is outside the search ceiling, monorepo where angular.json was renamed (e.g. workspace.json in Nx), or the devServer was misconfigured to use the Angular handler for a React/Vue project.

Related errors


AI-assisted analysis of cypress-io/cypress@0d85fdc912 (2026-08-12). Data as JSON: /api/errors/920bb987a7c7c41b. Report an issue: GitHub.