2017-02-02 31 views
0

任何人都可以給我一個工作package.json使angular2 AOT編譯通過? 我的包是如下:angular2 AOT總是失敗:這個package.json有什麼問題?

"dependencies": { 
    "@angular/common": "2.3.0", 
    "@angular/compiler": "2.3.0", 
    "@angular/compiler-cli": "2.3.0", 
    "@angular/core": "2.3.0", 
    "@angular/forms": "~2.1.1", 
    "@angular/http": "~2.1.1", 
    "@angular/platform-browser": "2.3.0", 
    "@angular/platform-browser-dynamic": "2.3.0", 
    "@angular/platform-server": "2.2.3", 
    "@angular/router": "~3.1.1", 
    "core-js": "^2.4.1", 
    "rxjs": "5.0.0-beta.12", 
    "socket.io": "^1.7.2", 
    "zone.js": "^0.6.25", 
    "typescript": "2.0.10", 
    }, 

後,我刪除所有node_modules和NPM一遍安裝,我跑:

node_modules/.bin/ngc -p tsconfig-aot.json 

我得到的錯誤數量巨大。

Error at angular2/ng2_webpack_aot/node_modules/typescript/lib/lib.es2015.core.d.ts:17:14: Duplicate identifier 'PropertyKey'. 
Error at angular2/ng2_webpack_aot/node_modules/@types/core-js/index.d.ts:21:14: Duplicate identifier 'PropertyKey'. 
Error at angular2/ng2_webpack_aot/node_modules/@types/core-js/index.d.ts:85:5: All declarations of 'name' must have identical modifiers. 
Error at angular2/ng2_webpack_aot/node_modules/@types/core-js/index.d.ts:145:5: Subsequent variable declarations must have the same type. Varia 
..... 

任何人都可以與我分享您的package.json配置,並且您能成功編譯AOT嗎?

我tsconfig-aot.json如下:

{ 
    "compilerOptions": { 
    "target": "es5", 
    "module": "es2015", 
    "moduleResolution": "node", 
    "sourceMap": true, 
    "emitDecoratorMetadata": true, 
    "experimentalDecorators": true, 
    "removeComments": false, 
"lib": ["es2015", "dom"], 
    "noImplicitAny": true, 
    "suppressImplicitAnyIndexErrors": true 
    }, 
"files": [ 
    "src/app/app.module.ts", 
    "src/main.ts" 
    ], 

    "angularCompilerOptions": { 
    "genDir": "aot", 
    "skipMetadataEmit" : true 
} 
} 
+0

當u得到這個錯誤?運行? Npm安裝? N開始? – Aravind

+0

顯示你的tsconfig? – vidalsasoon

+0

當我運行命令node_modules/.bin/ngc -p tsconfig-aot.json – user3006967

回答

1

其因core-js分型和打字稿es2015 11b是重疊的,儘量使用LIB的es5代替es2015

+0

這就是訣竅,爲什麼angular website提供了錯誤的信息?希望他們能改變它 – user3006967

0

降級打字稿的版本。卸載打印機版本2.0.10並安裝版本2.0.3。

+0

時出現錯誤,不幸的是typescript 2.0.3有相同的錯誤 – user3006967