cypress-io/cypress · error · SchematicsException
angular.json not found
Error message
angular.json not found
What it means
Raised by modifyAngularJson() during `ng add @cypress/schematic` when tree.exists('./angular.json') returns false. The schematic only knows how to register Cypress targets inside an existing angular.json; without it there is nothing to modify, so it throws a SchematicsException instead of silently skipping.
Source
Thrown at npm/cypress-schematic/src/schematics/ng-add/index.ts:314
addCypressTsConfig(tree, angularJsonVal, project)
context.logger.debug(`Adding cypress-run and cypress-open commands in angular.json`)
addNewCypressCommands(
tree,
angularJsonVal,
project,
runJson,
openJson,
e2eJson,
options.e2e,
componentJson,
options.component,
)
})
} else {
throw new SchematicsException('angular.json not found')
}
return tree
}
}
function addDefaultSchematic (): Rule {
return (tree: Tree, _: SchematicContext) => {
if (tree.exists('./angular.json')) {
const angularJsonVal = getAngularJsonValue(tree)
const angularSchematic = '@schematics/angular'
const cli = {
...angularJsonVal.cli,
schematicCollections: ['@cypress/schematic', ...angularJsonVal?.cli?.schematicCollections ?? []],
}
if (cli.schematicCollections.indexOf('@schematics/angular') === -1) {
cli.schematicCollections.push(angularSchematic)View on GitHub (pinned to 0d85fdc912)
Solutions
- `cd` to the directory that contains angular.json (usually the Angular workspace root) and re-run `ng add @cypress/schematic`.
- If angular.json is missing entirely, scaffold a standard Angular workspace with `ng new` first.
- If the file was renamed or moved, restore it to the workspace root before running the schematic.
- For Nx workspaces, confirm you are running an Angular CLI schematic against an Angular-style angular.json.
Example fix
# before: run from a subdir with no angular.json # after: cd /path/to/angular/workspace-root ng add @cypress/schematic
Defensive patterns
Strategy: validation
Validate before calling
import fs from 'fs'
if (!fs.existsSync('./angular.json')) {
throw new Error('No angular.json found in the current directory. Run ng add @cypress/schematic from the Angular workspace root.')
} Prevention
- Always run Angular schematics from the workspace root that contains angular.json.
- Verify angular.json exists before invoking `ng add @cypress/schematic`.
- Create the Angular workspace with `ng new` if starting fresh.
When it happens
Trigger: Running `ng add @cypress/schematic` from a directory that does not contain an angular.json file (e.g. a subdirectory, a non-Angular project, or a workspace where the file was renamed/deleted).
Common situations: Wrong working directory (running from a packages/subdir instead of the workspace root); a project that uses a different config file name; angular.json accidentally gitignored or removed; an Nx workspace using workspace.json instead.
Related errors
- projects in angular.json is not defined
- Invalid project name: ${options.project}
- File not found.
- Invalid project name: ${options.project}
- No file name specified. This is required to generate a new C
AI-assisted analysis of cypress-io/cypress@0d85fdc912 (2026-08-12).
Data as JSON: /api/errors/50058fa86709b1d8.
Report an issue: GitHub.