AppComponent is not declared in any Angular module PhpStorm inspection error not going away

45 views Asked by At

I generated a brand new angular application but I get "X is not declared in any Angular module" on every component I create. Even the AppComponent that is generated by Angular. I have the Angular plugin and I'm using the latest version.

I have tried:

  • Compiling on save with TypeScript in editor settings + tsconfig.json
  • invalidating caches
  • reinstalling everything
  • installing @angular/language-services

The program runs fine in VSCode and doesn't produce the same errors, but PhpStorm refuses to stop showing these errors.

2

There are 2 answers

0
M G On

All your components need to be either declared in some ngModule, or be standalone components, with flag like this

@Component({
 standalone: true
 ...
})
0
DeveloperLewis On

The issue was an outdated version of phpstorm (phpstorm 2022) and couldn't recognise the way angular ssr is using components and modules. Using the latest version of php storm solved this (phpstorm 2023)