在某些情况下,我刚刚开始浏览此处找到的 Ahead-of-time 编译食谱,尽管我不相信我的错误与它直接相关:https ://angular.io/guide/aot-compiler
我正在使用 Visual Studio 2015 并将我的 Angular 2 项目更新到新发布的 2.4 并且一切都构建得很好。但是,我随后更改了我的 tsconfig.json 文件以添加"lib": [ "es2015", "dom" ]
到我的 compilerOptions。该文件现在如下所示:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [ "es2015", "dom" ],
"removeComments": false,
"noImplicitAny": true,
"outDir": "dist",
"suppressImplicitAnyIndexErrors": true
},
"compileOnSave": true
}
进行此更改后,我重新构建并收到以下构建错误:
构建:重复标识符“PropertyKey”。
我做了一些研究并决定"@types/core-js": "^0.9.34"
从我的 package.json 文件中删除,这似乎已经解决了该错误,但我现在有以下新错误的几个实例:
构建:找不到名称“设置”
构建:找不到名称“承诺”
构建:找不到名称“地图”
这是我的完整 package.json 文件:
{
"name": "angular2-quickstart",
"version": "1.0.0",
"scripts": {
"start": "tsc && concurrently \"tsc -w\" \"lite-server\" ",
"docker-build": "docker build -t ng2-quickstart .",
"docker": "npm run docker-build && docker run -it --rm -p 3000:3000 -p 3001:3001 ng2-quickstart",
"pree2e": "npm run webdriver:update",
"e2e": "tsc && concurrently \"http-server -s\" \"protractor protractor.config.js\" --kill-others --success first",
"lint": "tslint ./app/**/*.ts -t verbose",
"lite": "lite-server",
"postinstall": "typings install",
"test": "tsc && concurrently \"tsc -w\" \"karma start karma.conf.js\"",
"test-once": "tsc && karma start karma.conf.js --single-run",
"tsc": "tsc",
"tsc:w": "tsc -w",
"typings": "typings",
"webdriver:update": "webdriver-manager update"
},
"license": "MIT",
"dependencies": {
"@angular/common": "~2.4.0",
"@angular/compiler": "~2.4.0",
"@angular/compiler-cli": "^2.4.1",
"@angular/core": "~2.4.0",
"@angular/forms": "~2.4.0",
"@angular/http": "~2.4.0",
"@angular/platform-browser": "~2.4.0",
"@angular/platform-browser-dynamic": "~2.4.0",
"@angular/platform-server": "^2.4.1",
"@angular/router": "~3.4.0",
"@angular/upgrade": "~2.4.0",
"angular-in-memory-web-api": "~0.1.16",
"bootstrap": "^3.3.7",
"core-js": "^2.4.1",
"reflect-metadata": "^0.1.8",
"rxjs": "5.0.1",
"systemjs": "0.19.39",
"zone.js": "^0.7.4"
},
"devDependencies": {
"@types/node": "^6.0.45",
"concurrently": "^3.0.0",
"lite-server": "^2.2.2",
"typescript": "^2.0.3"
},
"repository": {}
}
为了保持更新新版本,我几乎一直在此处复制示例 package.json 文件的依赖项部分:https ://angular.io/guide/quickstart
该链接适用于 JavaScript 版本,因为这是我能找到的唯一一个,但我实际上使用的是 TypeScript 2.1.4。正因为如此,我可能有这个文件的某些部分已经过时了。我只是不确定如何具体确定哪些部分。