首页 文章

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

提问于
浏览
1

我试图将我的角度应用程序部署到GitHub页面,同时结束这个我发现很难理解的长错误 . 我在网上试过,但似乎没有任何帮助 . 任何建议/帮助将不胜感激 .

谢谢

Background

角度版本: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.

1 回答

  • 0

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

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

    如果在角度应用程序中多次使用CountryViewComponent,则必须在共享模块中声明此状态,并在应用程序模块中声明共享模块 .

相关问题