ionic-team/ionic-framework · error · SchematicsException

Could not find project: ${projectName}

Error message

Could not find project: ${projectName}

What it means

Thrown by the Ionic Angular schematic helper getAngularJson() when the requested project name is not a key in the workspace's angular.json "projects" map. The schematic cannot proceed because it needs a concrete project target to mutate (styles, assets, architect builders). It surfaces as an Angular SchematicsException during `ng add @ionic/angular` or any Ionic schematic that takes a `--project` flag.

Source

Thrown at packages/angular/src/schematics/utils/config.ts:51

export function getDefaultAngularAppName(config: any): string {
  const projects = config.projects;
  const projectNames = Object.keys(projects);

  for (const projectName of projectNames) {
    const projectConfig = projects[projectName];
    if (isAngularBrowserProject(projectConfig)) {
      return projectName;
    }
  }

  return projectNames[0];
}

function getAngularJson(config: any, projectName: string): any | never {
  // eslint-disable-next-line no-prototype-builtins
  if (!config.projects.hasOwnProperty(projectName)) {
    throw new SchematicsException(`Could not find project: ${projectName}`);
  }

  const projectConfig = config.projects[projectName];
  if (isAngularBrowserProject(projectConfig)) {
    return projectConfig;
  }

  if (config.projectType !== 'application') {
    throw new SchematicsException(`Invalid projectType for ${projectName}: ${config.projectType}`);
  } else {
    const buildConfig = projectConfig.architect.build;
    throw new SchematicsException(`Invalid builder for ${projectName}: ${buildConfig.builder}`);
  }
}

export function addStyle(host: Tree, projectName: string, stylePath: string): void {
  const config = readConfig(host);
  const angularJson = getAngularJson(config, projectName);

View on GitHub (pinned to 625f9c38ad)

Solutions

  1. Run `ng config projects` (or open angular.json) and copy the exact key under "projects" to use as the `--project` value.
  2. Re-run the schematic with the correct flag: `ng add @ionic/angular --project <exact-project-key>`.
  3. If the workspace has no application project yet, generate one first (`ng generate application`) then re-run the schematic.
  4. Ensure you run `ng add` from the directory that contains the angular.json you intend to modify.

Example fix

// before
ng add @ionic/angular --project myApp
// after (use the exact key from angular.json#projects)
ng config projects   // list keys, e.g. { "my-app": {...}, "my-app-e2e": {...} }
ng add @ionic/angular --project my-app
Defensive patterns

Strategy: validation

Validate before calling

// Run before invoking the schematic (or before calling getAngularJson in a custom one)
import { readFileSync } from 'fs';
const angularJson = JSON.parse(readFileSync('angular.json', 'utf8'));
const projectExists = Object.prototype.hasOwnProperty.call(angularJson.projects ?? {}, projectName);
if (!projectExists) {
  throw new Error(`Project '${projectName}' not found. Available: ${Object.keys(angularJson.projects ?? {}).join(', ')}`);
}

Type guard

function isKnownProject(config: { projects?: Record<string, unknown> }, name: string): boolean {
  return !!config.projects && Object.prototype.hasOwnProperty.call(config.projects, name);
}

Prevention

When it happens

Trigger: Calling `ng add @ionic/angular --project <name>` (or addStyle/addAsset/addArchitectBuilder internally) where `<name>` does not match any key in `angular.json#projects`. Also fires when `getDefaultAngularAppName` falls back to `projectNames[0]` and that first project is the one passed onward but the user later renamed/removed it.

Common situations: Typo in the `--project` flag; workspace has multiple projects (e.g. app + app-e2e) and the wrong/non-existent one was targeted; project was renamed in angular.json but the schematic was invoked with the old name; running the schematic from a sub-folder so a different angular.json is resolved.

Related errors


AI-assisted analysis of ionic-team/ionic-framework@625f9c38ad (2026-08-12). Data as JSON: /api/errors/17a7265d8f5ef9d5. Report an issue: GitHub.