Skip to content
Nilay Kabariya

Entry No.029·Fixes··2 min read

Angular compilation initialization failed on TypeScript 7

Angular 22 crashes on TypeScript 7 with reading 'Error', not the usual version warning. What actually failed, and the setup that builds with tsc 7, tested.

The error, verbatim

Jump to the fix ↓
Application bundle generation failed. [0.412 seconds]
X [ERROR] Angular compilation initialization failed. [plugin angular-compiler]

  TypeError: Cannot read properties of undefined (reading 'Error')
      at readConfiguration (.../node_modules/@angular/compiler-cli/bundles/chunk-6MPH2PTO.js:507:42)
      at AotCompilation.loadConfiguration (.../@angular/build/src/tools/angular/compilation/typescript-compilation.js:61:121)
✓ Reproduced on Windows 11 Pro

Tested on

Angular
22.2.0
TypeScript
6.0.x / 7.0.2 / side-by-side
Node
24.15.0
OS
Windows 11 Pro
Contents
  1. The fix01
  2. Why it says reading 'Error'02
  3. Where is “The Angular Compiler requires TypeScript…”?03
  4. The Node.js error you may hit first04
  5. What didn’t work05
  6. How this was tested06

You upgraded to TypeScript 7, and ng build fails in under half a second. Angular’s peer range says it wants TypeScript >=6.0 <6.1, but npm installed 7.0.2 without stopping, so instead of a clear version message you get a crash from inside the compiler.

The fix

Keep TypeScript 7 for tsc, and give Angular the TypeScript 6 API it’s built on. This is the side-by-side setup Microsoft describes in the TypeScript 7.0 announcement:

npm install -D "@typescript/native@npm:typescript@7.0.2" "typescript@npm:@typescript/typescript6@^6.0.2"

Then delete node_modules and install again, and check which compiler tsc is:

npx tsc --version

Or stay on TypeScript 6 until Angular supports 7. A fresh ng new project comes with typescript ~6.0.2, and that built without errors:

npm install -D typescript@~6.0.2

Why it says reading 'Error'

On TypeScript 7.0.2 the typescript package exports only two things:

node -p "Object.keys(require('typescript'))"
# [ 'version', 'versionMajorMinor' ]

Angular’s compiler calls TypeScript’s compiler API to read your tsconfig.json, and that call fails because the API isn’t there. Angular catches the failure and tries to turn it into a friendly error message, using ts.DiagnosticCategory.Error. That doesn’t exist on TypeScript 7 either, so the error handler crashes too.

That’s line 507 of the file in the stack trace:

} catch (e) {
  const errors = [
    {
      category: ts5.DiagnosticCategory.Error,

So the message you see is the second failure, hiding the first. Nothing is wrong with your tsconfig.json.

Where is “The Angular Compiler requires TypeScript…”?

Most search results for a TypeScript mismatch in Angular show a clear version message, “The Angular Compiler requires TypeScript >=… but … was found”. On Angular 22.2.0 with TypeScript 7.0.2, neither ng build nor ng serve showed it: both failed with the same reading 'Error' crash in the first half-second.

If you’re searching for that older message, the cause is the same kind of mismatch, and the fix above applies.

The Node.js error you may hit first

Before any of this, the Angular 22 CLI refused to run at all on Node 24.14.0:

Node.js version v24.14.0 detected.
The Angular CLI requires a minimum Node.js version of v22.22.3 or v24.15.0 or v26.0.0.

Updating Node fixes it. To try a newer Node without changing the one installed on your machine, npx can run the CLI under a specific version:

npx -p node@24.15.0 -p @angular/cli ng version

What didn’t work

How this was tested

A fresh project from ng new --defaults (Angular 22.2.0, TypeScript 6.0.x as generated), built once as generated, then with typescript@7.0.2, then with the side-by-side setup after a clean reinstall. Every command ran under Node 24.15.0 through npx. The crash, the line in the compiler and the success messages above are copied from those runs.

— N.K., end of entry No.029

Useful? Pass it on:Post on XFollow @EmotionalMatter

Related entries

  1. No.022

    Fix: typescript-eslint does not support TS 7.0 (ESLint on TS 7)

    When typescript-eslint will support TypeScript 7, why npm refuses the install, and the setup that keeps TypeScript 7 while ESLint runs normally today.

    > npm error code ERESOLVE

    FIXED3 min
  2. No.016

    Fix: Cannot read properties of undefined (reading 'fileExists')

    ts-node and webpack's ts-loader crash with this on TypeScript 7, before your code even runs. Which versions do it, why npm didn't warn you, and four ways out.

    > C:\project\node_modules\ts-node\dist\configuration.js:91

    FIXED3 min
  3. No.031

    TypeScript 7 migration guide: breaking changes, tested

    Every option TypeScript 6.0.3 marked as deprecated was a hard error on 7.0.2, and ignoreDeprecations no longer silences it. Two defaults that arrived in 6.0 (strict on, @types not loaded automatically) also break projects coming straight from 5.9.

    TESTED6 min

Post card · Newsletter

Get the next fix in your inbox.

One short email when a new entry is published. No spam, never shared, and you can leave any time.

— Nilay

or follow by RSSor on X

By subscribing you agree to the privacy note. One click to leave.

tip: paste the exact error text