angular2 AOT 总是失败:这个 package.json 有什么问题吗?
angular2 AOT always failing: anything wrong with this package.json?
任何人都可以给我一个工作 package.json 来使 angular2 AOT 编译通过吗?
我的包裹如下:
"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
}
}
降级打字稿版本。卸载 typescript 版本 2.0.10 并安装版本 2.0.3.
这是由于 core-js
和打字稿 es2015
lib 的打字重叠,请尝试使用 lib es5
而不是 es2015
任何人都可以给我一个工作 package.json 来使 angular2 AOT 编译通过吗? 我的包裹如下:
"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
}
}
降级打字稿版本。卸载 typescript 版本 2.0.10 并安装版本 2.0.3.
这是由于 core-js
和打字稿 es2015
lib 的打字重叠,请尝试使用 lib es5
而不是 es2015