gpt4 book ai didi

Angular 看到错误的 Typescript 版本

转载 作者:行者123 更新时间:2023-12-03 23:49:39 29 4
gpt4 key购买 nike

这个问题在这里已经有了答案:





The Angular Compiler requires TypeScript >=3.4.0 and <3.5.0 but 3.5.3 was found instead

(16 个回答)


1年前关闭。




当我跑 ng build我收到以下错误:

ERROR in The Angular Compiler requires TypeScript >=3.4.0 and <3.6.0 but 3.7.4 was found instead.



但在我的 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"
}
}

最佳答案

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

您可以使用 ~Tilde Ranges而是允许补丁级别更改:

"typescript": "~3.5.3"

或者指定使用 准确版本您应该指定版本号(假定隐含 = 默认值),例如:
"typescript": "3.5.3"

关于Angular 看到错误的 Typescript 版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59515076/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com