angular/angular-cli · error · SchematicsException

Server schematic requires a project type of "application".

Error message

Server schematic requires a project type of "application".

What it means

Thrown by the server schematic when the resolved project's projectType extension is not "application" (e.g. it is a "library"). SSR server builds only make sense for applications, so the schematic refuses to proceed.

Source

Thrown at packages/schematics/angular/server/index.ts:170

        type: DependencyType.Default,
        install,
      }),
      addDependency('@angular/platform-server', coreDep.version, {
        type: DependencyType.Default,
        install,
      }),
      addDependency('@types/node', latestVersions['@types/node'], {
        type: DependencyType.Dev,
        install,
      }),
    ]);
  };
}

const serverSchematic: RuleFactory<ServerOptions> = createProjectSchematic(
  async (options, { project, tree }) => {
    if (project?.extensions.projectType !== 'application') {
      throw new SchematicsException(`Server schematic requires a project type of "application".`);
    }

    const clientBuildTarget = project.targets.get('build');
    if (!clientBuildTarget) {
      throw targetBuildNotFoundError();
    }

    const usingApplicationBuilder = isUsingApplicationBuilder(project);

    if (
      project.targets.has('server') ||
      (usingApplicationBuilder && clientBuildTarget.options?.server !== undefined)
    ) {
      // Server has already been added.
      return noop();
    }

    const clientBuildOptions = clientBuildTarget.options as Record<string, string>;

View on GitHub (pinned to bb72145f9a)

Solutions

  1. Re-run the schematic targeting an application: `ng g @angular/ssr:server --project <app-name>`.
  2. If the target should be an app, fix projectType to "application" in angular.json (and provide build/target config).
  3. Add SSR only to application projects; libraries cannot host an SSR server build.
  4. Check `ng list` to confirm which workspace entries are applications.

Example fix

// before (angular.json)
"my-lib": { "projectType": "library", ... }
// after — run against the app instead
"my-app": { "projectType": "application", ... }
Defensive patterns

Strategy: validation

Validate before calling

const ws = JSON.parse(fs.readFileSync('angular.json', 'utf8'));
const p = ws.projects?.[projectName];
if (p?.projectType !== 'application') {
  throw new Error(`Project '${projectName}' is not an application; SSR schematic will fail.`);
}

Type guard

function isApplication(p: { projectType?: string } | undefined): p is { projectType: 'application' } {
  return p?.projectType === 'application';
}

Try / catch

try {
  await generateServerSchematic({ project: projectName });
} catch (e) {
  if (String(e.message).includes('project type of "application"')) {
    console.error(`'${projectName}' is not an application. Target an app project.`);
  } else throw e;
}

Prevention

When it happens

Trigger: Running `ng generate @angular/ssr:server --project <lib>` against a library project (project.extensions.projectType === 'library'), or a project whose angular.json entry lacks projectType: application.

Common situations: Trying to add SSR to an Angular library; projects hand-created in angular.json without the projectType extension; running the schematic with the wrong --project name pointing at a library in a monorepo.

Related errors


AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30). Data as JSON: /api/errors/d12ec2e8a8b316d9. Report an issue: GitHub.