angular/angular-cli · error

${analysis.errorMessage}

Error message

${analysis.errorMessage}

What it means

The ivy plugin creates an analyzingFileEmitter that first awaits a pendingAnalysis promise wrapping the Angular program analysis/creation. If that analysis promise rejects, the rejection is captured as { errorMessage } and re-thrown as a plain Error when any file is emitted. This converts an asynchronous setup failure (typically from createProgram or its .catch at plugin.ts:622) into a webpack-emission-time error, surfacing the underlying analysis message.

Source

Thrown at packages/ngtools/webpack/src/ivy/plugin.ts:622

        return {
          emitter: this.createFileEmitter(
            builder,
            mergeTransformers(angularCompiler.prepareEmit().transformers, transformers),
            getDependencies,
            (sourceFile) => {
              this.requiredFilesToEmit.delete(normalizePath(sourceFile.fileName));
              angularCompiler.incrementalCompilation.recordSuccessfulEmit(sourceFile);
            },
          ),
        };
      })
      .catch((err) => ({ errorMessage: err instanceof Error ? err.message : `${err}` }));

    const analyzingFileEmitter: FileEmitter = async (file) => {
      const analysis = await pendingAnalysis;

      if ('errorMessage' in analysis) {
        throw new Error(analysis.errorMessage);
      }

      return analysis.emitter(file);
    };

    return {
      fileEmitter: analyzingFileEmitter,
      builder,
      internalFiles: ignoreForEmit,
    };
  }

  private updateJitProgram(
    compilerOptions: CompilerOptions,
    rootNames: readonly string[],
    host: CompilerHost,
    diagnosticsReporter: DiagnosticsReporter,
  ) {

View on GitHub (pinned to bb72145f9a)

Solutions

  1. Read the wrapped message (analysis.errorMessage) — the real cause is the underlying analysis failure it re-throws; fix that error first (type/template/diagnostic reported there).
  2. Align versions of @angular/compiler-cli, @ngtools/webpack, typescript, and @angular/* packages to compatible releases.
  3. Validate tsconfig paths/options used by the Angular builder (paths, target, angularCompilerOptions).
  4. Rebuild from a clean state (delete node_modules/.cache, dist) to rule out stale incremental state.

Example fix

// before: mismatched toolchain
"typescript": "~5.5",
"@angular/compiler-cli": "^17.0.0"

// after: aligned versions
"typescript": "~5.2",
"@angular/compiler-cli": "^17.0.0"
Defensive patterns

Strategy: try-catch

Validate before calling

// Before building, catch analysis failures early via a dry type-check:
// npx tsc -p tsconfig.app.json --noEmit
// and verify toolchain versions match:
const ts = require('typescript');
const cli = require('@angular/compiler-cli/package.json');
if (cli.peerDependencies && !require('semver').satisfies(ts.version, cli.peerDependencies.typescript)) {
  throw new Error(`typescript ${ts.version} incompatible with @angular/compiler-cli (${cli.peerDependencies.typescript})`);
}

Try / catch

try {
  const stats = await runWebpack(config);
} catch (err) {
  if (err instanceof Error && /ngtools|analysis|program/i.test(err.message)) {
    console.error('Angular AOT analysis failed; run tsc --noEmit and check compiler-cli/typescript version alignment:', err.message);
    process.exit(1);
  }
  throw err;
}

Prevention

When it happens

Trigger: The Angular compiler program creation/analysis fails while webpack is already emitting files (e.g. TypeScript diagnostics or program creation threw), so any subsequent file emitter call observes 'errorMessage' in the analysis result and throws it.

Common situations: TypeScript/Angular template type errors severe enough to fail program creation; incompatible @angular/compiler-cli vs typescript versions causing analysis to reject; tsconfig path/option errors that make the underlying program creation fail; out-of-memory or crash inside the AOT analysis.

Related errors


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