ionic-team/ionic-framework · error · SchematicsException

Invalid projectType for ${projectName}: ${config.projectType

Error message

Invalid projectType for ${projectName}: ${config.projectType}

What it means

Thrown by getAngularJson() when the project exists but isAngularBrowserProject() returned false, AND the code could not confirm `config.projectType === 'application'`. Note the source reads `config.projectType` (the root-level field) rather than the per-project `projectConfig.projectType`, so in a standard Angular workspace this branch is hit whenever the targeted project is not recognized as a browser/application project — the message typically reports `undefined`.

Source

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

    }
  }

  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);
  angularJson.architect.build.options.styles.push({
    input: stylePath,
  });
  writeConfig(host, config);
}

export function addAsset(
  host: Tree,
  projectName: string,

View on GitHub (pinned to 625f9c38ad)

Solutions

  1. Open angular.json and confirm the targeted project has `"projectType": "application"` and an `architect.build` target.
  2. Re-run the schematic targeting the actual application project (see the keys in angular.json#projects).
  3. If you must use a library/e2e project, that is unsupported — point the schematic at the browser application project instead.
  4. If the project really is an application but uses a non-standard builder, see the related 'Invalid builder' error and switch to a supported builder.

Example fix

// before (targeting a library)
ng add @ionic/angular --project shared-lib
// after
grep '"projectType"' angular.json   // locate the "application" project
ng add @ionic/angular --project my-app
Defensive patterns

Strategy: validation

Validate before calling

import { readFileSync } from 'fs';
const angularJson = JSON.parse(readFileSync('angular.json', 'utf8'));
const project = angularJson.projects?.[projectName];
if (!project) throw new Error('project missing');
if (project.projectType !== 'application') {
  throw new Error(`${projectName} is ${project.projectType}, expected 'application'`);
}

Type guard

function isApplicationProject(project: { projectType?: string }): boolean {
  return project?.projectType === 'application';
}

Prevention

When it happens

Trigger: Targeting a project whose `projectType` is `library`, or an `application` project whose build target is not one of the three recognized browser/application builders. Because the check uses the root config's `projectType`, most non-browser projects land here.

Common situations: Running an Ionic schematic against an Angular library project; targeting an `app-e2e` or server-only project; workspace where the only application project uses a custom/unsupported builder so isAngularBrowserProject() returns false.

Related errors


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