Mateusz Witkowski
Mateusz Witkowski

Reputation: 1746

Angular-CLI AOT - error stack trace

Does anyone know how to get more detailed error stack trace while using Angular CLI with AOT compiling? There's no issue in my app when running with JIT compilation but when I run ng build --aot all I get is: TypeError: Cannot read property "length" of undefined. There's no info where's the source of error. I suppose there's some issue in one of my templates but I don't have idea which one is the problem.

I'm using latest versions of Angular CLI (1.0.0-beta.24) and Angular 2 (2.4.1).

EDIT

Here's the full message from the compilator while using ng serve --aot command:

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

Upvotes: 3

Views: 2225

Answers (2)

Marc
Marc

Reputation: 681

also had this error message using the AOT compiler. In my case, it was a problem with a token in the providers configuration of the app module that didn't work with AOT. See https://www.bennadel.com/blog/3138-creating-a-custom-errorhandler-in-angular-2-rc-6.htm?&_=0.39111966827042277#comments_48858

Upvotes: 1

shusson
shusson

Reputation: 5772

I've had this before and it can be a real pain. Have you tried ng serve --aot and looking at the stack trace in the browser?

I've narrowed down these issues in the past by removing code incrementally using a binary search strategy :/

Upvotes: 0

Related Questions