2017-01-04 13 views
2

誰も、AOTコンパイルでAngular CLIを使用している間、より詳細なエラースタックトレースを取得する方法を知っていますか?私のアプリではJITコンパイルを実行しても問題はありませんが、ng build --aotを実行すると、私にはすべてTypeError: Cannot read property "length" of undefinedと表示されます。エラーの原因はどこにありません。テンプレートの1つに問題があると思われますが、どちらが問題かはわかりません。Angular-CLI AOTエラースタックトレース

最新のAngular CLI(1.0.0-beta.24)とAngular 2(2.4.1)を使用しています。私は前にこれを持っていた

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 
+0

いくつかのコードを投稿する必要があります。どのように変数の "長さ"を持っていますか? –

+0

アプリケーションはかなり複雑です。それは何百ものテンプレートと対応する.tsファイルを持っているので残念ながらコードを投稿することは不可能です。 JITコンパイルでは、初期化されていない変数や空の配列を使って* ngFor命令でループしようとしたときに、そのような種類のエラー(「プロパティを読み込めません」など)が発生することがありました。 JITコンパイルを使用している可能性があります。tsconfig.jsonに何かを入れてコンパイラにそのようなエラーの完全なスタックトレースを表示させることは可能でしょうか? –

+0

afaik beta.24は2.3.1で動作するようになっています – shusson

答えて

0

、それは本当の痛みをすることができます:ng serve --aotコマンドを使用している間

EDITはここcompilatorからの完全なメッセージです。 ng serve --aotを試して、ブラウザのスタックトレースを見ましたか?

私は二分探索戦略を使用してインクリメンタルコードを削除することで、過去にこれらの問題を絞り込むました:/

+0

エラーメッセージブラウザから( 'ng serve --aot'を使って)。 –

関連する問題