Accepted answer

I was installing the latest typescript: 4.0.2 npm packages thats why the NGCC error occured

run the below command and it will work,

npm i typescript@">=3.9.2 <4.0.0”

this is about the typescript version so just install the valid typescript and you will fix the ngcc error

Accepted answer

similar issue with Angular 12 and Node 17.4.0. I changed Node to v16.13.2 and now it works fine.

Accepted answer

Run below command npm i @ngtools/webpack and after @ mention version you want, same as your Angular version.

npm i @ngtools/webpack@9.1.15

whatever version of Angular you are using choose the same version.

Version              Downloads (Last 7 Days)             Tag
12.2.14                           101,188               v12-lts
8.3.29                             60,775               v8-lts
9.1.15                             57,568               v9-lts
7.3.10                             34,584               v7-lts

open extension list in vscode like you can see below image and select Angular Language Service extension. and open extension settings then uncheck below two items and reinstall node module.



woked for me del node_modules npm install enableIvy:false was not support who uses angular v12 or above

Downgrading typescript (4.8 to 4.6 in my case) resolved the issue.

npm i rimraf -g
rimraf node_modules
npm i

First step:

ng update @angular/cli @angular/core

Second step:

ng update

Third step:

ng serve

remove the node_modules folder and run install again:

rm -rf node_modules
npm install

it has solved the problem.

Adding "postinstall": "ngcc" to "scripts" in package.json helped me to fix this

adding following to the tsconfig.app.json:

"angularCompilerOptions": {
    "enableIvy": false
},

My error:

Unknown arguments: use-program-dependencies, useProgramDependencies
An unhandled exception occurred: NGCC failed.
See "C:\...\angular-errors.log" for further details.

updated angular cli, material and core, and other modules needed to my project, then updated npm and typescript package, and that's all.

ng update @angular/cli @angular/core
npm update @angular/material @angular/cdk
npm install -g typescript@latest