角度看到错误的打字稿版本

时间:2019-12-28 21:37:32

标签: angular typescript angular-cli

运行ng build时出现以下错误:

  

Angular编译器中的错误需要TypeScript> = 3.4.0和<3.6.0,但是找到了3.7.4。

但是在我的package.json中,我定义了"typescript": "^3.5.3"

我在项目中的文件3.7.4中找到了一个文件,但是找不到它,所以Angular-CLI为什么认为这是指定的版本?

我正在使用节点12.13.0。

这是我的完整package.json

{
  "name": "my-app",
  "version": "0.0.0",
  "scripts": {
    "postinstall": "npm run build",
    "ng": "ng",
    "dev": "ng build --aot --watch",
    "dtos": "tsd-ref && ts-ref",
    "build": "ng build --prod",
    "publish": "npm run build",
    "lint": "ng lint",
    "test": "ng test",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^8.2.14",
    "@angular/common": "^8.2.14",
    "@angular/compiler": "^8.2.14",
    "@angular/core": "^8.2.14",
    "@angular/forms": "^8.2.14",
    "@angular/http": "^7.2.15",
    "@angular/platform-browser": "^8.2.14",
    "@angular/platform-browser-dynamic": "^8.2.14",
    "@angular/router": "^8.2.14",
    "@servicestack/angular": "0.0.8",
    "@servicestack/client": "^1.0.31",
    "bootstrap": "^4.4.1",
    "core-js": "^3.6.1",
    "rxjs": "^6.5.4",
    "zone.js": "^0.9.1"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.803.21",
    "@angular/cli": "^8.3.21",
    "@angular/compiler-cli": "^8.2.14",
    "@angular/language-service": "^8.2.14",
    "@types/jasmine": "^3.5.0",
    "@types/jasminewd2": "^2.0.8",
    "@types/node": "^12.12.22",
    "codelyzer": "^5.2.1",
    "gulp": "^4.0.2",
    "jasmine-core": "^3.5.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "^4.4.1",
    "karma-chrome-launcher": "~3.0.0",
    "karma-coverage-istanbul-reporter": "^2.1.1",
    "karma-jasmine": "^2.0.1",
    "karma-jasmine-html-reporter": "^1.5.1",
    "protractor": "^5.4.2",
    "ts-node": "^8.5.4",
    "tslint": "^5.20.1",
    "typescript": "^3.5.3"
  }
}

1 个答案:

答案 0 :(得分:2)

npm semver docs解释了不同运算符的含义,例如^Caret Ranges允许升级到下一个主要版本。

您可以改用~Tilde Ranges来更改补丁程序级别:

"typescript": "~3.5.3"

或者要指定使用确切版本,您应该指定版本号(假定默认为=),例如:

"typescript": "3.5.3"