I use angular 13.3. I have a project that name is "pazh-base-source" that some of my base component is in it such as pazh-component.ts . I want to use this components in my main project. I export the pazh-component in app module in pazh-base-source, also I set the CUSTOM_ELEMENTS_SCHEMA in schemas in app-module of my both project (main and pazh-base-source). I use "ng-packagr -p ng-package.json && cd dist && npm publish"
to publish pazh-base-source and then use npm i pazh-base-source
and import it in my app-module in main project but when I use "ng-packagr -p ng-package.json && cd dist && npm publish"
in main project to publish it, I get this error:
error image: my error, error code:
src/app/app.component.html:1:1 - error NG8001: 'pazh-component' is not a known element:
1. If 'pazh-component' is an Angular component, then verify that it is part of this module.
2. If 'pazh-component' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
my app.component.ts of main source:
<pazh-component>
<p>test</p>
</pazh-component>
my app.module.ts of main source:
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AppRoutingModule,
PazhComponentsModule
],
providers: [],
exports: [
AppComponent
],
bootstrap: [AppComponent],
schemas: [
CUSTOM_ELEMENTS_SCHEMA
]
})
my pazh-component.module:
@NgModule({
imports: [
CommonModule,
FormsModule
],
declarations: [
PazhComponentComponent,
],
exports: [
PazhComponentComponent,
],
schemas: [
NO_ERRORS_SCHEMA,
CUSTOM_ELEMENTS_SCHEMA,
],
providers: [
PazhFormBuilderService,
ReferralService
],
})
I also check the selectors and other way that angular.io said.