什么是x.ngfactory.ts文件,以及如何在I';m使用@angular/cli 1.1.1

什么是x.ngfactory.ts文件,以及如何在I';m使用@angular/cli 1.1.1,angular,webpack-2,typescript2.0,Angular,Webpack 2,Typescript2.0,我使用的是angular 4.x、webpack 2.x、typescript 2.x 我正在使用@angular/cli构建我的项目 但是,当我在执行ng service时,它工作得很好,所有代码都被成功地传输,并且在视图中运行得非常好 其日志如下: webpack: Compiling... Hash: 24b7c2a082104ba0df53 Time: 9187ms chun

我使用的是angular 4.x、webpack 2.x、typescript 2.x

我正在使用@angular/cli构建我的项目

但是,当我在执行
ng service
时,它工作得很好,所有代码都被成功地传输,并且在视图中运行得非常好

其日志如下:

webpack: Compiling...
Hash: 24b7c2a082104ba0df53                                                         
Time: 9187ms
chunk    {0} main.bundle.js, main.bundle.js.map (main) 661 kB {3} [initial] [rendered]
chunk    {1} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 160 kB {4} [initial]
chunk    {2} styles.bundle.js, styles.bundle.js.map (styles) 285 kB {4} [initial]
chunk    {3} vendor.bundle.js, vendor.bundle.js.map (vendor) 5.69 MB [initial]
chunk    {4} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry]
webpack: Compiled successfully.
但是,当我执行
ng build--prod时,它会抛出以下几个错误:

ERROR in F:/$$$A4p/chatbox/clientV2/src/$$_gendir/app/component/profile/view/people/people.component.ngfactory.ts (1292,11): Type 'MProfile | IConversationProfile' is not assignable to
type 'boolean'.
  Type 'MProfile' is not assignable to type 'boolean'.

ERROR in F:/$$$A4p/chatbox/clientV2/src/$$_gendir/app/component/profile/view/conversation/conv.component.ngfactory.ts (950,11): Type 'MProfile | IConversationProfile' is not assignable
to type 'boolean'.
  Type 'MProfile' is not assignable to type 'boolean'.

ERROR in F:/$$$A4p/chatbox/clientV2/src/$$_gendir/local_node_modules/ngx-uploader/src/module/ngx-uploader.module.ngfactory.ts (10,26): Cannot find module './ngx-uploader.module'.

ERROR in F:/$$$A4p/chatbox/clientV2/src/$$_gendir/app/component/profile/view/people/people.component.ngfactory.ts (1292,11): Type 'MProfile | IConversationProfile' is not assignable to
type 'boolean'.
  Type 'MProfile' is not assignable to type 'boolean'.

ERROR in F:/$$$A4p/chatbox/clientV2/src/$$_gendir/app/component/profile/view/conversation/conv.component.ngfactory.ts (950,11): Type 'MProfile | IConversationProfile' is not assignable
to type 'boolean'.
  Type 'MProfile' is not assignable to type 'boolean'.
但当我搜索任何
…ngfactory.ts
时,它不在文件系统中。

所以我不知道如何调试这些错误


NgFactory文件是页面运行时的真实文件。在开发阶段,您有模板文件和.ts文件。当您使用
ng build--prod
它也运行AOT,AOT首先将这两个文件合并到NGFactorys中。JIT也在做类似的事情,但是在运行时

如果没有AOT,则不会出现相同的错误,因为JIT会忽略这些模板错误

检查你的模板文件,你有类型铸造错误,如

Type 'MProfile' is not assignable to type 'boolean'.

没有源代码就很难判断发生了什么。虽然它与AOT有关,但我无法在没有源代码的情况下说是什么触发了错误遗憾的是,这并不能真正回答问题的第二部分,即如何调试它们。