【问题标题】:Ho to deploy angular app with ng build --aot?如何使用 ng build --aot 部署 Angular 应用程序?
【发布时间】:2020-10-03 13:17:29
【问题描述】:

我在 localhost 中使用 angular 创建了一个网站,一切正常,在 heroku 中也可以正常工作,现在我想将页面部署到我的服务器,

这里是回购:agency repo

我运行以下命令

ng build --aot

不幸的是,我收到以下错误

ERROR in : Type NgStickyDirective in C:/custom-xammp/htdocs/agency/majeni/node_modules/ng-sticky/ng-sticky.d.ts is part of the declarations of 2 modules: AppModule in C:/custom-xammp/htdocs/agency/majeni/src/app/app.module.ts and NgStickyModule in C:/custom-xammp/htdocs/agency/majeni/node_modules/ng-sticky/ng-sticky.d.ts! Please consider moving NgStickyDirective in C:/custom-xammp/htdocs/agency/majeni/node_modules/ng-sticky/ng-sticky.d.ts to a higher module that imports AppModule in C:/custom-xammp/htdocs/agency/majeni/src/app/app.module.ts and NgStickyModule in C:/custom-xammp/htdocs/agency/majeni/node_modules/ng-sticky/ng-sticky.d.ts. You can also create a new NgModule that exports and includes NgStickyDirective in C:/custom-xammp/htdocs/agency/majeni/node_modules/ng-sticky/ng-sticky.d.ts then import that NgModule in AppModule in C:/custom-xammp/htdocs/agency/majeni/src/app/app.module.ts and NgStickyModule in C:/custom-xammp/htdocs/agency/majeni/node_modules/ng-sticky/ng-sticky.d.ts.

我需要做什么来解决这个问题?

【问题讨论】:

    标签: javascript angular typescript ng-build


    【解决方案1】:

    错误是关于在您的模块 AppModule 中重新声明的第 3 部分指令。

    确保您的AppModuledeclarations 中没有NgStickyDirective。只需在您的imports 中添加NgStickyModule 就足够了。

    declarations: [/* only your own components and directives*/],
    imports: [NgStickyModule, /* other modules*/ ]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-07-28
      • 1970-01-01
      • 1970-01-01
      • 2017-03-18
      • 2010-10-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多