angular/angular-cli · error · SchematicsException

Cannot find 'options' for ${projectName} ${target} target.

Error message

Cannot find 'options' for ${projectName} ${target} target.

What it means

The Angular SSR schematic needs to read the `outputPath` from the project's build target options to rewire output paths. This error is thrown when the target exists in angular.json but has no `options` object at all, so the schematic cannot locate any output configuration.

Source

Thrown at packages/schematics/angular/ssr/index.ts:60

import { Schema as SSROptions } from './schema';

const SERVE_SSR_TARGET_NAME = 'serve-ssr';
const PRERENDER_TARGET_NAME = 'prerender';
const DEFAULT_BROWSER_DIR = 'browser';
const DEFAULT_MEDIA_DIR = 'media';
const DEFAULT_SERVER_DIR = 'server';

async function getLegacyOutputPaths(
  host: Tree,
  projectName: string,
  target: 'server' | 'build',
): Promise<string> {
  // Generate new output paths
  const workspace = await readWorkspace(host);
  const project = workspace.projects.get(projectName);
  const architectTarget = project?.targets.get(target);
  if (!architectTarget?.options) {
    throw new SchematicsException(`Cannot find 'options' for ${projectName} ${target} target.`);
  }

  const { outputPath } = architectTarget.options;
  if (typeof outputPath !== 'string') {
    throw new SchematicsException(
      `outputPath for ${projectName} ${target} target is not a string.`,
    );
  }

  return outputPath;
}

async function getApplicationBuilderOutputPaths(
  host: Tree,
  projectName: string,
): Promise<{ browser: string; server: string; base: string }> {
  // Generate new output paths
  const target = 'build';

View on GitHub (pinned to bb72145f9a)

Solutions

  1. Open angular.json and add an `options` object with at least an `outputPath` (string) to the project's `build` target.
  2. Regenerate angular.json from a fresh `ng new` project and re-apply your customizations.
  3. Verify the project/target names passed to the schematic match entries in angular.json (`ng config projects.<name>.architect.build.options`).
  4. Regenerate the workspace config with `ng generate config` or restore it from version control.

Example fix

// before (angular.json)
"build": { "configurations": { "production": {} } }
// after
"build": {
  "options": { "outputPath": "dist/my-app" },
  "configurations": { "production": {} }
}
Defensive patterns

Strategy: validation

Validate before calling

const project = (await readWorkspace(host)).projects.get(projectName);
const target = project?.targets.get('build');
if (!target?.options) {
  throw new Error(`Project ${projectName} build target has no options; add outputPath to angular.json before running the SSR schematic.`);
}
if (typeof target.options.outputPath !== 'string') {
  throw new Error(`outputPath of ${projectName} build target is not a string.`);
}

Type guard

function hasTargetOptions(t: { options?: Record<string, unknown> } | undefined): t is { options: Record<string, unknown> } {
  return !!t && typeof t.options === 'object' && t.options !== null;
}

Try / catch

try {
  await schematicPromise;
} catch (e) {
  if (e instanceof SchematicsException && e.message.includes("Cannot find 'options'")) {
    console.error('Fix angular.json: add options.outputPath to the build target.');
  }
  throw e;
}

Prevention

When it happens

Trigger: Running the `ng add @angular/ssr` (or ssr schematic) on a workspace where `angular.json` defines the project's `build` (or specified) target without an `options` section — e.g. the target only has `configurations`, or options were manually removed.

Common situations: Hand-edited angular.json that stripped `options`; workspaces generated by non-CLI tools; custom builders whose options live only under a configuration; partial/corrupt angular.json after a migration.

Related errors


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