I'm working on building out a, Angular library, and keep running into an error like this:
projects/my-lib/src/lib/components/my-comp/my-comp.component.html:3:5 - error NG8001: 'lib-other-comp' is not a known element: 1. If 'lib-other-comp' is an Angular component, then verify that it is part of this module. 2. If 'lib-other-comp' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
I was banging my head around this for a while. Why couldn't one component in an Angular library, find the other component in an Angular library?
First, make sure that both components are listed in a module:
2 declarations: [
3 MyCompComponent,
4 OtherCompComponent
5 ],
6 imports: [
7 CommonModule
8 ],
9 exports: [
10 MyCompComponent,
11 OtherCompComponent
12 ],
13})
14export class MyLibModule { }
If that doesn't help, make sure that all injected providers for both myComp and OtherComp are listed in the provider array. Sometimes that can cause odd issues.
You'll find a lot of these suggestions on-line. But, my components are listed, my providers are synced properly, why am I still getting the error?
Inside the library public-api.ts make sure to export your module:
Once I properly exported the module everything started magically working. My fault, I just missed an export.