{"record":{"id":"a24de1c61d3fdc42","repo":"angular/angular-cli","slug":"analysis-errormessage","errorCode":null,"errorMessage":"${analysis.errorMessage}","messagePattern":"\\$\\{analysis\\.errorMessage\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/ngtools/webpack/src/ivy/plugin.ts","lineNumber":622,"sourceCode":"        return {\n          emitter: this.createFileEmitter(\n            builder,\n            mergeTransformers(angularCompiler.prepareEmit().transformers, transformers),\n            getDependencies,\n            (sourceFile) => {\n              this.requiredFilesToEmit.delete(normalizePath(sourceFile.fileName));\n              angularCompiler.incrementalCompilation.recordSuccessfulEmit(sourceFile);\n            },\n          ),\n        };\n      })\n      .catch((err) => ({ errorMessage: err instanceof Error ? err.message : `${err}` }));\n\n    const analyzingFileEmitter: FileEmitter = async (file) => {\n      const analysis = await pendingAnalysis;\n\n      if ('errorMessage' in analysis) {\n        throw new Error(analysis.errorMessage);\n      }\n\n      return analysis.emitter(file);\n    };\n\n    return {\n      fileEmitter: analyzingFileEmitter,\n      builder,\n      internalFiles: ignoreForEmit,\n    };\n  }\n\n  private updateJitProgram(\n    compilerOptions: CompilerOptions,\n    rootNames: readonly string[],\n    host: CompilerHost,\n    diagnosticsReporter: DiagnosticsReporter,\n  ) {","sourceCodeStart":604,"sourceCodeEnd":640,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/ngtools/webpack/src/ivy/plugin.ts#L604-L640","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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).","Align versions of @angular/compiler-cli, @ngtools/webpack, typescript, and @angular/* packages to compatible releases.","Validate tsconfig paths/options used by the Angular builder (paths, target, angularCompilerOptions).","Rebuild from a clean state (delete node_modules/.cache, dist) to rule out stale incremental state."],"exampleFix":"// before: mismatched toolchain\n\"typescript\": \"~5.5\",\n\"@angular/compiler-cli\": \"^17.0.0\"\n\n// after: aligned versions\n\"typescript\": \"~5.2\",\n\"@angular/compiler-cli\": \"^17.0.0\"","handlingStrategy":"try-catch","validationCode":"// Before building, catch analysis failures early via a dry type-check:\n// npx tsc -p tsconfig.app.json --noEmit\n// and verify toolchain versions match:\nconst ts = require('typescript');\nconst cli = require('@angular/compiler-cli/package.json');\nif (cli.peerDependencies && !require('semver').satisfies(ts.version, cli.peerDependencies.typescript)) {\n  throw new Error(`typescript ${ts.version} incompatible with @angular/compiler-cli (${cli.peerDependencies.typescript})`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  const stats = await runWebpack(config);\n} catch (err) {\n  if (err instanceof Error && /ngtools|analysis|program/i.test(err.message)) {\n    console.error('Angular AOT analysis failed; run tsc --noEmit and check compiler-cli/typescript version alignment:', err.message);\n    process.exit(1);\n  }\n  throw err;\n}","preventionTips":["Run tsc --noEmit (or ng build with AOT) locally before CI so analysis failures surface early.","Pin compatible versions of @angular/compiler-cli, @ngtools/webpack, and typescript.","Keep tsconfig angularCompilerOptions valid and free of experimental/mismatched options.","Clear webpack/node_modules caches (node_modules/.cache) after upgrading Angular to avoid stale analysis state."],"tags":["webpack","angular","aot","compilation","plugin"],"backgroundTag":"aot-analysis-failed","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}