2016-09-06 16 views
1

私はWindows 7 x64にあり、私のAngular 2アプリケーションのAhead-of-Time compilationの指示に従おうとしています。アプリはジャストインタイムのコンパイルでうまくコンパイルして実行します。角度2の予期しないコンパイラエラー

私はNPMはngcを実行するときに、私は次のエラーを取得する@angular/[email protected][email protected]@angular/[email protected]@angular/[email protected]

をインストールしている:ここで

C:\websites\learn\angular2>"node_modules/.bin/ngc" -p dev 
can't resolve module @angular/core/src/di/opaque_token from C:\...\dev\index.ts 
TypeError: undefined is not a function 
    at ReflectorHost.findDeclaration (C:\...\node_modules\@angular\compiler-cli\src\reflector_host.js:171:59) 
    at StaticReflector.initializeConversionMap (C:\...\node_modules\@angular\compiler-cli\src\static_reflector.js:150:38) 
    at new StaticReflector (C:\...\node_modules\@angular\compiler-cli\src\static_reflector.js:42:14) 
    at Function.CodeGenerator.create (C:\...\node_modules\@angular\compiler-cli\src\codegen.js:142:31) 
    at codegen (C:\...\node_modules\@angular\compiler-cli\src\main.js:7:36) 
    at Object.main (C:\...\node_modules\@angular\tsc-wrapped\src\main.js:30:16) 
    at Object.<anonymous> (C:\...\node_modules\@angular\compiler-cli\src\main.js:14:9) 
    at Module._compile (module.js:460:26) 
    at Object.Module._extensions..js (module.js:478:10) 
    at Module.load (module.js:355:32) 
Compilation failed 

は私のフォルダ構造である(tsconfig.jsonがトップレベルでangular2です) : enter image description here

一見すると、th eエラーはsimilar to this oneと思われますが、詳細を見ると、鉱山(「未定義は関数ではありません」)が異なっています。何か案は?

+0

https://github.com/角度/角度/問題/ 10792 –

+0

ちょっと@GünterZöchbauer。私はその問題を投稿する前に見ました。その場合、 'ngc'は実際に実行することができます。期待されるファイルは生成されません。 '.ngfactory.ts'の代わりに' .js'、 '.js.map'、' .json'ファイルを出力します。私の場合、 'ngc'クラッシュとして何も出力されない – BeetleJuice

答えて

0

これは、インストールしたノードのバージョンと関係があります。

$ node --version 
v0.12.7 

$ npm --version 
3.7.5 

は、私がダウンロードしてhttps://nodejs.org/en/download/から最新の64ビット.msiインストーラインストールした後:

$ node --version 
v4.5.0 

$ npm --version 
2.15.9 

エラーが発生しなくなったがこれも関係している可能性

+9

私はノードv6.2.2とnpm v3.9.5を使用していますが、私はまだこのエラーを受けています – brando

+3

@brando同じエラーが発生しています。解決できましたか? –

関連する問題