【问题标题】:PrimeNG(Angular) modules missing in production mode but available in development modePrimeNG(Angular)模块在生产模式下缺失但在开发模式下可用
【发布时间】:2020-11-29 09:04:27
【问题描述】:

我一直在开发一个使用 PrimeNG 作为 UI 组件的 Angular 应用程序。最初我使用 Angular 9 和 PrimeNG 8,我可以毫无问题地进行部署。所以几个月前我将我的 PrimeNG 版本更新到 10.0.5-rc1 版本,因为有一些我想要的新功能。 开发进展顺利,但是当我尝试在生产模式下构建我的 Angular 应用程序时,每个使用 PrimeNG 组件的组件都会引发错误。我注意到的另一件事是,每当我尝试从共享模块访问组件时,找不到该组件,因为 Angular 在生产模式下无法找到共享模块。这是引发的错误类型的药水。

    35   templateUrl: './reservation.component.html',
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Error occurs in the template of component ReservationComponent.
src/app/modules/sales/modules/pos/menus/home/reservations/reservation/reservation.component.html:390:65 - error NG8002: Can't bind to 'showCloseIcon' since it isn't a known property of 'p-overlayPanel'.
1. If 'p-overlayPanel' is an Angular component and it has 'showCloseIcon' input, then verify that it is part of this module.
2. If 'p-overlayPanel' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.

390 <p-overlayPanel #deletePaymentOverlayModal [dismissable]="true" [showCloseIcon]="true">

  src/app/modules/sales/modules/pos/menus/home/reservations/reservation/reservation.component.ts:35:16
    35   templateUrl: './reservation.component.html',
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Error occurs in the template of component ReservationComponent.
src/app/modules/shared/pos/reservation-components/create-reservation/create-reservation.component.html:3:1 - error NG8001: 'app-create-edit-reservation' is not a known element:
1. If 'app-create-edit-reservation' is an Angular component, then verify that it is part of this module.
2. If 'app-create-edit-reservation' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.

3 <app-create-edit-reservation></app-create-edit-reservation>

我尝试更新我的 PrimeNG 版本,现在它是最新版本,即 11.0.0-rc1。我还更新了我的 angular 和 angular cli 版本。

我该如何解决这个问题?

【问题讨论】:

  • 您是否已将应用程序的 Angular 版本更新到 V10?
  • 当我运行ng update 命令时,它已更新到角度版本 9.1.12。即使我运行其他命令,如 ng update @angular/cli ng update @angluar/core
  • 我什至尝试升级到 Angular 版本 10,然后升级到版本 20,但它仍然无法编译。

标签: angular typescript primeng


【解决方案1】:

通过更改angular.json 文件中的一些变量,我获得了在生产模式下构建的角度。

angular.json重构前的文件:

"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,

angular.json重构后的文件:

"namedChunks": false,
"aot": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": false,

我认为我需要在应用程序中更正一些东西,也许摆脱一些去头库等。

【讨论】:

    猜你喜欢
    • 2020-08-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-26
    • 2021-03-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多