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)
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
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 --versionOr 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.2Why 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