Angular Error: 'Component 'X' is not included in a module...' when declared in a sub module

I had this same issue and this is how it got resolved :

1) Goto Intellij / IDE settings and tick(set) the Recompile on changes to :

enter image description here

2) Goto tsconfig.json and set the compileOnSave to true :

enter image description here

Now go and remove the @Component that's causing the issue, and retype @Component.

This worked for me :) Good Luck.


First: declare all your components in declarations section (app.module.ts).

If the problem persist, I remember that is a problem with the beta angular-cli versions.

The issue you are running into is a variant of the baseUrl issue. The language service does not correctly respect the baseUrl option. For example, if you change the import of the shared module from app/shared/shared.module to ../shared/shared.module then the errors go away.