将我的 angular 应用程序部署到 gh-page 时出错

Error in deploying my angular app to gh-page

我试图将我的 angular 应用程序部署到 GitHub 页面,但最终出现了这个我觉得很难理解的长错误。我在网上试过,但似乎无济于事。 任何 suggestions/help 将不胜感激。

谢谢

背景

Angular version: 6.1.2

用于部署应用程序的命令:

npm install -g angular-cli-ghpages

ng build --prod --base-href repository link

错误

    > 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.

发生这种情况是因为您在模块 app.module 和共享模块中都声明了 CountryViewComponent 组件。

对于解决方案,您必须根据您的要求从一个模块中删除 CountryViewComponent。

如果 CountryViewComponent 在您的 angular 应用程序中多次使用,则您必须在共享模块中声明它并且共享模块在应用程序模块中声明。