我用的是角4.x,webpack 2.x,打字本2.x。
我正在使用@ar角/cli构建我的项目。
但是,当我执行ng serve时,它工作得很好,所有的代码都被成功地转换了,并且在视图中运行得非常好。
其日志如下:
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 时,它并不存在于文件系统.中。
所以我不知道如何调试这些错误。
发布于 2017-06-11 14:59:48
NgFactory文件是页面运行时的真实文件。在开发阶段,您有模板文件和.ts文件。当您使用ng build --prod编译项目时,它也会运行AOT,并将这两个文件优先合并到ngFactories中。JIT也做了类似的事情,但在运行时。
如果没有AOT,您不会得到相同的错误,因为JIT会忽略那些模板错误。
查看您的模板文件,您有类型的强制转换错误,如
Type 'MProfile' is not assignable to type 'boolean'.https://stackoverflow.com/questions/44484811
复制相似问题