I was trying to deploy my angular app, to GitHub-page, while ending up with this long error which I am finding difficult to understand. I tried online but nothing seems to help. Any suggestions/help would be appreciated.
Thanks
Background
Angular version: 6.1.2
Command Used to deploy the app:
npm install -g angular-cli-ghpages
ng build --prod --base-href repository link
Error
> ERROR in : Type CountryViewComponent in
> /localpath/country-view.component.ts
> is part of the declarations of 2 modules: AppModule in
> /localpath/app.module.ts and SharedModule in
> /localpath/shared.module.ts! Please
> consider moving CountryViewComponent in
> /localpath/country-view.component.ts
> to a higher module that imports AppModule in
> /localpath/app.module.ts and SharedModule in
> /localpath/shared.module.ts. You can
> also create a new NgModule that exports and includes
> CountryViewComponent in
> /localpath/country-view/country-view.component.ts
> then import that NgModule in AppModule in
> /localpath/app.module.ts and SharedModule in
> /localpath/shared.module.ts.
This happens because you declared CountryViewComponent component in both module app.module and shared module.
For solution you have to remove CountryViewComponent from one module as per your requirements.
if CountryViewComponent is used in multiple time within your angular app than you have to declare this in shared module and shared module is declare in app module.