Angular: Component X is not included in a module and will not be available inside a template
Asked Answered
S

5

10

In my Angular application, I have few components which are used while testing and not included in any module.

In WebStorm, it shows me a lint error saying Component is not included in any module, while I know that this is not included and that is the purpose.

Is there a way to disable only this lint error while keeping all others enabled?

Angular: Component 'ComponentName' is not included in a module and will not be available inside a template. Consider adding it to a NgModule declaration.

I saw this threat, where it was suggested to disable all Angular lint errors. However, i think it is not a good idea to do that just for one issue. I am looking for a way to only disable this one error.

Simon answered 16/11, 2017 at 19:10 Comment(1)
I also met this error which prevents me from running the UT, appreciates it if you can share your solutions if the problem has been solved.Nonfulfillment
M
5

Worked for me:

File -> Invalidate Caches / Restart -> Invalidate and restart

Micronucleus answered 25/6, 2018 at 11:35 Comment(1)
I think this one worked for me. I will validate little more and confirm you @FilipSimon
N
3

Angular language service doesn't provide a possibility to suppress particular rules/checks. Please follow https://github.com/angular/angular/issues/13726 for updates

Nigrosine answered 17/11, 2017 at 11:28 Comment(2)
Running npm install @angular/language-service and restarting IDE, resolved the problem. @angular/language-service updated to version 5.2.0Quarterphase
Why it does not do automatically. Why we have to install an extra thing to get only that in IDE?Simon
F
3

I use PHPStorm and found this problem also when using Angular 4. I fixed it by npm install @angular/language-service.

Finial answered 17/7, 2018 at 7:44 Comment(1)
Had the same issue with visual studio code. And the same solution worked.Griffen
S
0

On Webstorm you can just press Alt+Enter and it will display a list, where you can choose disable inspection, and it will update rules of inspection automatically to all same cases.

Spheroidal answered 9/4, 2018 at 8:44 Comment(0)
W
0

You can add the following comment above the class declaration and it will skip the check for that class:

// noinspection AngularMissingOrInvalidDeclarationInModule

You can also get the editor to add that comment for you by using the contextual menu you get when you hover over the error and going to 'Inspection options > Suppress for statement'

Wheezy answered 28/7, 2020 at 2:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.