angular/angular-cli · error · SchematicsException
Invalid project name (${projectName})
Error message
Invalid project name (${projectName}) What it means
addServerFile resolves the project named by `options.project` in the workspace to generate server.ts and wire build targets. If no project with that name exists in angular.json, it throws this SchematicsException early.
Source
Thrown at packages/schematics/angular/ssr/index.ts:347
install,
}),
);
}
return chain(rules);
}
function addServerFile(
projectSourceRoot: string,
options: ServerOptions,
isStandalone: boolean,
): Rule {
return async (host) => {
const projectName = options.project;
const workspace = await readWorkspace(host);
const project = workspace.projects.get(projectName);
if (!project) {
throw new SchematicsException(`Invalid project name (${projectName})`);
}
const usingApplicationBuilder = isUsingApplicationBuilder(project);
const browserDistDirectory = usingApplicationBuilder
? (await getApplicationBuilderOutputPaths(host, projectName)).browser
: await getLegacyOutputPaths(host, projectName, 'build');
return mergeWith(
apply(url(`./files/${usingApplicationBuilder ? 'application-builder' : 'server-builder'}`), [
applyTemplates({
...strings,
...options,
browserDistDirectory,
isStandalone,
}),
move(projectSourceRoot),
]),
);
};View on GitHub (pinned to bb72145f9a)
Solutions
- List valid projects with `ng list` (or check `projects` in angular.json) and pass the exact name via `--project`.
- Fix the project name typo in your command/script.
- If the project was renamed, rename it back in angular.json or update all references before running the schematic.
Example fix
// before ng add @angular/ssr --project myapp // after ng add @angular/ssr --project my-app
Defensive patterns
Strategy: validation
Validate before calling
import { readFileSync, existsSync } from 'fs';
const aj = JSON.parse(readFileSync('angular.json', 'utf8'));
const name = 'my-app'; // value you pass via --project
if (!existsSync('angular.json') || !aj.projects?.[name]) {
throw new Error(`Project "${name}" not found. Valid: ${Object.keys(aj.projects ?? {}).join(', ')}`);
} Type guard
null
Try / catch
try {
await runSchematic('ng-add', { project: name });
} catch (e) {
if (String(e?.message).startsWith('Invalid project name')) {
console.error(`Check project names with "ng list"; you passed: ${name}`);
}
throw e;
} Prevention
- Verify the project name with `ng list` before running the schematic.
- Copy/paste project keys from angular.json instead of retyping them.
- Update scripts/CI after renaming projects in angular.json.
- Use consistent project naming conventions across the monorepo.
When it happens
Trigger: Running the ssr schematic with `--project` set to a name not present in `projects` of angular.json; typo in the project name; running in a repo where angular.json doesn't contain the expected project.
Common situations: Typos like `--project myapp` vs `my-app`; running after renaming a project without updating scripts/CI; monorepos where the schematic is invoked against another package's name.
Related errors
- Cannot find 'options' for ${projectName} ${target} target.
- outputPath for ${projectName} ${target} target is not a stri
- Cannot find "${configFilePath}".
- Cannot find the "provideServerRendering" function call in "$
- Project name "${options.project}" doesn't not exist.
AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30).
Data as JSON: /api/errors/5f29ec9a80e2c61a.
Report an issue: GitHub.