1

我正在尝试构建我的 Angular 8 应用程序的生产版本,但我经常遇到Property '*' does not exist on type '*'错误。

执行的命令:

ng build --prod="true" --verbose=true

收到的错误:

ERROR in src/app/shared/layout/sidenav/sidenav.component.html(1,46): : Property 'always' does not exist on type 'SidenavComponent'.
src/app/shared/layout/sidenav/sidenav.component.html(1,97): : Property 'scrollViewExtras' does not exist on type 'SidenavComponent'.
src/app/shared/layout/sidenav/sidenav.component.html(1,128): : Property 'scrollBarExtras' does not exist on type 'SidenavComponent'.
src/app/shared/layout/sidenav/sidenav.component.html(10,41): : Property 'sidenav' is private and only accessible within class 'SidenavComponent'.

这些是前 3 行src/app/shared/layout/sidenav/sidenav.component.html

<ng-scrollbar class="notice-board-scrollbar" [shown]="always" [compact]="true" [invertY]="true" [viewClass]="scrollViewExtras" [barClass]="scrollBarExtras">
  <cdk-virtual-scroll-viewport ngScrollbarView smoothScroll itemSize="100">
    <mat-list role="list">

--prod="true"如果我在没有标志的情况下构建或执行ng serve,它编译时不会出错。

riverman@vscode:~/projects/front$ ng version  

Angular CLI: 8.0.3
Node: 10.16.1
OS: linux x64
Angular: 8.0.2
... animations, cdk, common, compiler, compiler-cli, core
... elements, forms, language-service, platform-browser

Package                             Version
-------------------------------------------------------------
@angular-devkit/architect           0.800.3
@angular-devkit/build-angular       0.800.3
@angular-devkit/build-optimizer     0.800.3
@angular-devkit/build-webpack       0.800.3
@angular-devkit/core                8.0.1
@angular-devkit/schematics          8.0.3
@angular/cli                        8.0.3
@angular/material                   8.0.1
@angular/platform-browser-dynamic   8.0.1
@angular/router                     8.0.1
@ngtools/webpack                    8.0.3
@schematics/angular                 8.0.3
@schematics/update                  0.800.3
rxjs                                6.5.2
typescript                          3.4.5
webpack                             4.30.0

提前感谢您的帮助!

4

1 回答 1

2

我最近遇到了这个问题,希望这对其他人有用,因为它对我有用,

在生产配置下更新 angular.json

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

于 2020-05-20T12:46:11.660 回答