Angular Compile Error: NG6001: The class is listed in the declarations of the NgModule 'AppModule', but is not a directive, a component, or a pipe

You have to run npm install when creating new components. Hot reload doesn't seem to be able to add the component.


I had the same issue. Removing OnInit in the declaration part as well as inside the class helped me. Because it initialized all data-bound properties of the directive. Since this component could have been added in app.module.ts.

export class NavigationMenuItemComponent {
     ....
     ....
     set iconClass(iconClass) {
            this._iconClass = NavigationMenuItemComponent.ID_PREFIX + iconClass;
        }

        //ngOnInit(): void {}
    }

Add these lines in component:

constructor() {};

ngOnInit(): void {};

I am also facing same issue but I think the error occurs because angular is no more treating it as complete component by adding contructor and ngOnIt have fixed issue.