Angular-CLI AOT - 错误堆栈跟踪

时间:2017-01-04 21:05:39

标签: angular angular-cli angular2-aot

在使用带有AOT编译的Angular CLI时,有谁知道如何获得更详细的错误堆栈跟踪?使用JIT编译时,我的应用程序中没有问题但是当我运行ng build --aot时,我得到的是:TypeError: Cannot read property "length" of undefined。没有信息,哪里是错误的来源。我想我的一个模板中存在一些问题,但我不知道哪个是问题。

我使用的是最新版本的Angular CLI(1.0.0-beta.24)和Angular 2(2.4.1)。

修改

使用ng serve --aot命令时,来自编译器的完整信息:

Cannot read property 'length' of undefined

./app/main.ts
Module not found: Error: Can't resolve './$$_gendir/app.module.ngfactory' in 'C:\frontend-angular-cli\app'
resolve './$$_gendir/app.module.ngfactory' in 'C:\frontend-angular-cli\app'
using description file: C:\frontend-angular-cli\package.json (relative path: ./app)
Field 'browser' doesn't contain a valid alias configuration
after using description file: C:\frontend-angular-cli\package.json (relative path: ./app)
using description file: C:\frontend-angular-cli\package.json (relative path: ./app/$$_gendir/app.module.ngfactory)
as directory
C:\frontend-angular-cli\app\$$_gendir\app.module.ngfactory doesn't exist
no extension
Field 'browser' doesn't contain a valid alias configuration
C:\frontend-angular-cli\app\$$_gendir\app.module.ngfactory doesn't exist
.ts
Field 'browser' doesn't contain a valid alias configuration
C:\frontend-angular-cli\app\$$_gendir\app.module.ngfactory.ts doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
C:\frontend-angular-cli\app\$$_gendir\app.module.ngfactory.js doesn't exist
[C:\frontend-angular-cli\app\$$_gendir\app.module.ngfactory]
[C:\frontend-angular-cli\app\$$_gendir\app.module.ngfactory]
[C:\frontend-angular-cli\app\$$_gendir\app.module.ngfactory.ts]
[C:\frontend-angular-cli\app\$$_gendir\app.module.ngfactory.js]
@ ./app/main.ts 8:0-70
@ multi main

./~/@angular/core/src/linker/system_js_ng_module_factory_loader.js
Module not found: Error: Can't resolve 'C:\frontend-angular-cli\app\$$_gendir' in 'C:\frontend-angular-cli\node_modules\@angular\core\src\linker'
resolve 'C:\frontend-angular-cli\app\$$_gendir' in 'C:\frontend-angular-cli\node_modules\@angular\core\src\linker'
using description file: C:\frontend-angular-cli\node_modules\@angular\core\package.json (relative path: ./src/linker)
Field 'browser' doesn't contain a valid alias configuration
after using description file: C:\frontend-angular-cli\node_modules\@angular\core\package.json (relative path: ./src/linker)
using description file: C:\frontend-angular-cli\package.json (relative path: ./app/$$_gendir)
as directory
C:\frontend-angular-cli\app\$$_gendir doesn't exist
[C:\frontend-angular-cli\app\$$_gendir]
@ ./~/@angular/core/src/linker/system_js_ng_module_factory_loader.js 69:15-36 85:15-102
@ ./~/@angular/core/src/linker.js
@ ./~/@angular/core/src/core.js
@ ./~/@angular/core/index.js
@ ./app/main.ts
@ multi main

2 个答案:

答案 0 :(得分:1)

使用AOT编译器也有此错误消息。就我而言,app模块的提供程序配置中的令牌是一个问题,它不能与AOT一起使用。见https://www.bennadel.com/blog/3138-creating-a-custom-errorhandler-in-angular-2-rc-6.htm?&_=0.39111966827042277#comments_48858

答案 1 :(得分:0)

我以前有这个,这可能是一个真正的痛苦。您是否尝试过ng serve --aot并在浏览器中查看堆栈跟踪?

我过去通过使用二进制搜索策略逐步删除代码来缩小这些问题:/