繁体   English   中英

更新tsconfig.json和package.json后出错

[英]Errors after updating tsconfig.json and package.json

在某些情况下,我刚刚开始浏览这里发现的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'。

我做了一些研究并决定从我的package.json文件中删除"@types/core-js": "^0.9.34" ,这似乎解决了这个错误,但我现在有几个以下新错误的实例:

构建:找不到名称'Set'

建立:找不到名字'承诺'

构建:找不到名称'Map'

这是我的完整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。 因此,我可能有这个文件的某些部分已经过时了。 我只是不确定如何具体确定哪些部分。

我不熟悉Visual Studio设置(intellij用户)。 但也许尝试使用。 “lib”:[“es6”,“dom”],或者可能删除“lib”:[“es20125”,“dom”],完全尝试使用core-js @types。 看看我在这里如何使用core-js的答案。

相关答案:

Angular 2找不到Promise,Map,Set和Iterator

Cannot find name 'Promise'这个错误让我相信你错过了ES6的类型定义。

Promise,Map和Set是es6规范。

您应该使用ES6 pollyfill库。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM