Angular extension might not work correctly because ngcc operation failed

1.6k Views Asked by At

enter image description here

This is the error I am getting.

enter image description here

However ng serve is running without any issues.

enter image description here

I am also getting this is a problem but I have imported ReactiveFormsModule correctly and it is also working as expected in the website I am just getting this error randomly.

I tried deleting node_modules multiple times, I even deleted the npm cache folder in my Local but still getting this error after npm i. This is a new project I created with Angular 16.

{
  "name": "testProject",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "watch": "ng build --watch --configuration development",
    "test": "ng test"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^16.1.1",
    "@angular/common": "^16.1.1",
    "@angular/compiler": "^16.1.1",
    "@angular/core": "^16.1.1",
    "@angular/forms": "^16.1.1",
    "@angular/platform-browser": "^16.1.1",
    "@angular/platform-browser-dynamic": "^16.1.1",
    "@angular/router": "^16.1.1",
    "@ngrx/effects": "^16.0.1",
    "@ngrx/store": "^16.0.1",
    "@ngrx/store-devtools": "^16.0.1",
    "rxjs": "~7.8.0",
    "tslib": "^2.3.0",
    "zone.js": "~0.13.0"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^16.1.1",
    "@angular/cli": "^16.1.1",
    "@angular/compiler-cli": "^16.1.1",
    "@types/jasmine": "~4.3.0",
    "jasmine-core": "~4.6.0",
    "karma": "~6.4.0",
    "karma-chrome-launcher": "~3.2.0",
    "karma-coverage": "~2.2.0",
    "karma-jasmine": "~5.1.0",
    "karma-jasmine-html-reporter": "~2.1.0",
    "typescript": "~5.1.3"
  }
}

Any help and suggestions appreciated.

3

There are 3 best solutions below

0
On BEST ANSWER

My issue was with Visual Studio Code.

My Angular version is v16.1.1 but VS Code was somehow downloading Angular Language Service v15.2.4.

Reinstalled Visual Studio Code and it fixed the issue.

If you're having the same issue check if the Angular Language Service extension version and angular version are compatible.

1
On

Try removing lock file and node_modules and reinstall everything, ngcc was removed in angular 16. Maybe update angular extension as well.

1
On

Sriharish's answer also helped me resolve this issue. I started running into this issue after updating to Angular 16 and I couldn't figure out why. Turns out it was because VSCode kept installing version 15 for the Angular Language Service extension. I uninstalled and re-installed VSCode and that fixed the issue. Thanks Sriharish!