使用--prod
构建时出错 当我在没有--prod 的情况下构建时,项目成功运行
ng build&& node server.js
chunk {inline} inline.bundle.js, inline.bundle.js.map (inline) 5.83 kB [entry] [rendered]
chunk {main} main.bundle.js, main.bundle.js.map (main) 643 kB {vendor} [initial] [rendered]
chunk {polyfills} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 204 kB {inline} [initial] [rendered]
chunk {scripts} scripts.bundle.js, scripts.bundle.js.map (scripts) 755 kB {inline} [initial] [rendered]
chunk {styles} styles.bundle.js, styles.bundle.js.map (styles) 314 kB {inline} [initial] [rendered]
chunk {vendor} vendor.bundle.js, vendor.bundle.js.map (vendor) 3.53 MB [initial] [rendered]
API running on localhost:3000
但是当我使用--prod运行时,我会收到以下错误
ng build --prod&& node server.js
chunk {0} styles.650105909265b10581f3.bundle.css (styles) 214 kB {3} [initial] [rendered]
chunk {1} polyfills.3bc34265385d52184eab.bundle.js (polyfills) 86 bytes {3} [initial] [rendered]
chunk {2} main.e402deade8b026b7d50e.bundle.js (main) 84 bytes [initial] [rendered]
chunk {3} inline.38c436511d2cbf092b64.bundle.js (inline) 1.45 kB [entry] [rendered]
ERROR in ng:///C:/Users/USER/Documents/built-x-web/src/app/views/dashboard/dashboard.component.html (116,33): Operator '>' cannot b
e applied to types 'boolean' and 'number'.
ERROR in ng:///C:/Users/USER/Documents/built-x-web/src/app/views/dashboard/profile.component.html (334,52): Operator '>' cannot be
applied to types 'boolean' and 'number'.
ERROR in C:/Users/USER/Documents/built-x-web/src/$$_gendir/app/components/profile.component.ngfactory.ts (1362,43): Property 'quota
tion' does not exist on type 'FormGroup'.
ERROR in ng:///C:/Users/USER/Documents/built-x-web/src/app/views/dashboard/_searchProjectFilter.component.html (517,1): Operator '>
' cannot be applied to types 'boolean' and 'number'.
ERROR in ng:///C:/Users/USER/Documents/built-x-web/src/app/views/dashboard/_searchContactFilter.component.html (95,17): Operator '>
' cannot be applied to types 'boolean' and 'number'.
ERROR in ng:///C:/Users/USER/Documents/built-x-web/src/app/views/dashboard/projectDetails.component.html (437,33): Operator '>' can
not be applied to types 'boolean' and 'number'.
ERROR in ng:///C:/Users/USER/Documents/built-x-web/src/app/views/admin/reports.component.html (24,21): Operator '>' cannot be appli
ed to types 'boolean' and 'number'.
ERROR in ng:///C:/Users/USER/Documents/built-x-web/src/app/views/admin/projects.component.html (23,21): Operator '>' cannot be appl
ied to types 'boolean' and 'number'.
ERROR in ng:///C:/Users/USER/Documents/built-x-web/src/app/views/admin/projectView.component.html (593,33): Operator '>' cannot be
applied to types 'boolean' and 'number'.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! crux-app@0.0.0 buildPro: `ng build --prod && node server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the crux-app@0.0.0 buildPro script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\USER\AppData\Roaming\npm-cache\_logs\2017-10-27T11_08_40_065Z-debug.log
它就像在HTML文件中将尖括号(>)作为运算符。
HTML代码
<tr *ngFor="let point of points">
<!-- <td><a [routerLink]="['/dashboard/project-details/', point.opportunityId.id]"> {{point.opportunityId.name}}</a></td> -->
<td class="text-center">
<span *ngIf="point.points>0; else elseBlock">+{{point.points}}</span>
<ng-template #elseBlock>
<span >{{point.points}}</span>
</ng-template>
</td>
<td>{{point.title}}</td>
</tr>
错误出现在我已评论的行中。但是,如果我评论整个代码块,那么错误将转移到另一行。 -------------------------------------------------- ---------------------- code and error screenshot