Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular : 'CommonModule' does not appear to be an NgModule class.(-996002)

I'm working on a project that uses angular 8. Recently I started to get errors in all modules. When i hover over the commonModule import i get the following error message:

'CommonModule' does not appear to be an NgModule class.(-996002)
common.d.ts(43, 57): This likely means that the library (@angular/common) which declares CommonModule is not compatible with Angular Ivy. Check if a newer version of the library is available, and update if so. Also consider checking with the library's authors to see if the library is expected to be compatible with Ivy.

I also get errors for every directive in html files, like:

Can't bind to 'ngClass' since it isn't a known property of 'div'.ngtsc(-998002)

I have tried the solutions i've found online but none worked for me. I tried deleting the node modules folder and then running npm install. I have also enabled the legacy view engine in angular language service settings in VScode. When I changed the version of typescript of VSCode to the version used in the package.json of the project the problem, it seemed like the issue was solved, but soon the erros returned. Anyone has an ideia of whats going on?

like image 846
jgf Avatar asked Jan 19 '26 04:01

jgf


2 Answers

It seems to be somehow related VSCode, the following workaround has worked for me, I've:

  1. Removed the node_modules folder
  2. Cleared the npm cache npm cache clean --force
  3. With the project opened in the VSCode, I did the npm install, then did npm start from the project root in a terminal different from the VSCode terminal (iTerm2 in my case). This allowed to recompile the project and the error in VSCode was gone
like image 142
donny_barko Avatar answered Jan 20 '26 17:01

donny_barko


If you're not running a recent version of Angular with Ivy, install an earlier version of the Angular Language Service extension, for an Angular 8 project, version v11.1.3 seems to work fine-

like image 25
chrismarx Avatar answered Jan 20 '26 19:01

chrismarx