cypress-io/cypress · error · SchematicsException
Invalid project name: ${options.project}
Error message
Invalid project name: ${options.project} What it means
Raised by the cypress-test ng-generate schematic after workspaces.readWorkspace resolves, when neither options.project nor the workspace's defaultProject yields a project from workspace.projects.get(). The schematic needs a real project to compute the spec output path (project.sourceRoot / project.root / project.prefix), so an unresolved project is fatal.
Source
Thrown at npm/cypress-schematic/src/schematics/ng-generate/cypress-test/index.ts:49
}
}
export default function (options: Schema): Rule {
return async (tree: Tree) => {
const host = createSpec(tree)
const { workspace } = await workspaces.readWorkspace('/', host)
const testType = options.component ? 'component' : 'e2e'
let project
if (!options.project) {
project = workspace.projects.get(workspace.extensions.defaultProject as string)
} else {
project = workspace.projects.get(options.project)
}
if (!project) {
throw new SchematicsException(`Invalid project name: ${options.project}`)
}
if (options.name === undefined) {
throw new SchematicsException(`No file name specified. This is required to generate a new Cypress file.`)
}
if (options.path === undefined) {
options.path = testType === 'component' ? `${project.sourceRoot}/${project.prefix}` : `${project.root}/cypress/e2e`
}
console.log(`Creating new ${testType} spec named: ${options.name}`)
const templatePath = testType === 'component' ? '../files/ct/__path__' : '../files/e2e/__path__'
const templateSource = createTemplate({ templatePath, options })
return chain([
mergeWith(templateSource),
])View on GitHub (pinned to 0d85fdc912)
Solutions
- Pass the exact project name: `ng generate @cypress/schematic:cypress-test --project <name>` matching a key in angular.json projects.
- If omitting --project, set a defaultProject at the top level of angular.json so the fallback resolves.
- List valid projects with `ng config projects` or by inspecting angular.json, then use one of those names.
- Check for typos and case sensitivity in the project name.
Example fix
# before: ng g @cypress/schematic:cypress-test --project App # after: ng g @cypress/schematic:cypress-test --project app
Defensive patterns
Strategy: validation
Validate before calling
function resolveProjectName(options: { project?: string }, defaultProject?: string, projects: Record<string, unknown>) {
const name = options.project ?? defaultProject
if (!name || !(name in projects)) {
throw new Error(`Invalid or missing project name: ${String(name ?? options.project)}`)
}
return name
} Type guard
function isKnownProject(name: string, projects: Record<string, unknown>): name is string {
return name in projects
} Prevention
- Pass --project with a name that exists in angular.json projects.
- Set a defaultProject in angular.json if you want to omit --project.
- Check project name spelling and case before invoking the schematic.
When it happens
Trigger: Running `ng generate @cypress/schematic:cypress-test --project noSuch` where 'noSuch' is not a project in angular.json; OR running without --project when the workspace has no defaultProject (so the fallback lookup returns undefined).
Common situations: A typo in the --project name; a workspace with no defaultProject and no --project flag; a renamed project; an Angular CLI version that does not set options.project from the default.
Related errors
- Invalid project name: ${options.project}
- File not found.
- No file name specified. This is required to generate a new C
- projects in angular.json is not defined
- angular.json not found
AI-assisted analysis of cypress-io/cypress@0d85fdc912 (2026-08-12).
Data as JSON: /api/errors/1d1fb31c6e7dcd0c.
Report an issue: GitHub.