The class AppComponent is listed in the declarations of the NgModule AppModule, but is not a directive, a component, or a pipe. - Troubleshooting

Last update September 26, 2022 at 11:29 am

You are working on an Angular project then you encounter this error snippet: The class AppComponent is listed in the declarations of the NgModule AppModule, but is not a directive, a component, or a pipe….

Ce help concerns a type of problem that can be encountered during the development of a application with angular. Problems like this often have more than one solution, some of which will not match yours. In this article we add our grains of salt by offering you a solution that worked with our project.

 

The class AppComponent is listed in the declarations of the NgModule AppModule, but is not a directive, a component, or a pipe. - Troubleshooting Click to tweet

 

 



 





 

Solution for “The class AppComponent is listed in the declarations of the NgModule AppModule”:

 

The full message of the error that we are going to resolve this presents as such:

The class 'AppComponent' is listed in the declarations of the NgModule 'AppModule', but is not a directive, a component, or a pipe. Either remove it from the NgModule's declarations, or add an appropriate Angular decorator.

 

The cause in our case of this error is that the html code of the component angular AppComponent is badly written in the html.

To solve it you have to check the opening and closing tags of your html code. If the error persists, stop the program and restart it with the command ”Ng serve“ .

In our case the error came from a component which is badly written in AppComponent.

 

Subscribe to our newsletter

* Indicates required

 

Conclusion

 

You may be interested in Typescript: how to install it and tutorial for setting up the project with its unit test et Tutorial: How to install angular in ubuntu.

 

 

The class AppComponent is listed in the declarations of the NgModule AppModule, but is not a directive, a component, or a pipe. - Troubleshooting
Image by Jill Wellington from Pixabay

 

 

 

Leave comments

Your email address will not be published. Required fields are marked with *

two × three =