简体   繁体   English

Angular 2 AOT构建错误(找不到模块)

[英]Angular 2 AOT build error (module not found)

I'm trying to build an Angular 2 project for production, but the following error occurs (full output) 我正在尝试为生产构建一个Angular 2项目,但发生以下错误(完整输出)

$ ng build --prod
Hash: 1d8a022611a079fc4d52                                                         Time: 15057ms
chunk    {0} polyfills.6a841d7989dfdd57acf1.bundle.js (polyfills) 249 kB {5} [initial] [rendered]
chunk    {1} styles.872c1a24be4bf9c1223c.bundle.css (styles) 546 bytes {5} [initial] [rendered]
chunk    {2} scripts.938daa6986147a5346c9.bundle.js (scripts) 723 kB {5} [initial] [rendered]
chunk    {3} main.353b80e799563ca86907.bundle.js (main) 2.59 kB {4} [initial] [rendered]
chunk    {4} vendor.da282f8d8f035631cde9.bundle.js (vendor) 875 kB [initial] [rendered]
chunk    {5} inline.40400ad5f16398e09e79.bundle.js (inline) 0 bytes [entry] [rendered]

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '<project-root>/src'
 @ ./src/main.ts 17:0-74
 @ multi ./src/main.ts

I have fixed all issues from ng lint that are not just style issues. 我已经修复了ng lint中不仅仅是样式问题的所有问题。 I know that I need to export functions instead of "const lambda" and the other usual AoT things, but I can't find any issues and the error gives no hint of where to look. 我知道我需要导出函数而不是“const lambda”和其他常见的AoT东西,但是我找不到任何问题,错误也没有提示在哪里看。 I have tried with --verbose which didn't produce any useful information. 我尝试过--verbose没有产生任何有用的信息。

I have read all GitHub issues and SO questions I could find, but none has helped. 我已经阅读了所有GitHub问题以及我能找到的SO问题,但没有一个有帮助。

EDIT: It seems that it could have to do with using absolute paths in combination with bareUrl typescripts compiler options. 编辑:它似乎与使用绝对路径结合bareUrl编译器选项有关。

Eventually this came down to two tsconfig.json issues. 最终这归结为两个tsconfig.json问题。 First I was mistakenly including some mock files that there used for tests only. 首先,我错误地包含了一些仅用于测试的模拟文件。 Second I was including typings.d.ts in the include section of tsconfig.json which also broke the build. 其次我在typings.d.tsinclude部分中includetsconfig.json ,这也破坏了构建。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM