gpt4 book ai didi

javascript - 无法更新 Angular 版本

转载 作者:搜寻专家 更新时间:2023-10-30 21:25:14 25 4
gpt4 key购买 nike

我正在尝试升级我的 Angular 应用程序。我的 Angular 应用程序的版本是 4.2.4 for Basic Apps。我正在使用 Angular Update Guide 中给出的步骤.

按照指南,我必须运行以下命令

npm install -g @angular/cli
npm install @angular/cli
ng update @angular/cli

但是当我尝试执行命令时

ng update @angular/cli

它给我一个错误提示

Error: Cannot update safely because packages have conflicting dependencies. Package @angular/core would need to match both versions "7.2.15" and "8.2.7, which are not compatible.
Cannot update safely because packages have conflicting dependencies. Package @angular/core would need to match both versions "7.2.15" and "8.2.7, which are not compatible.

这就是我的 package.json 的样子

{
"name": "stellar",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^4.2.4",
"@angular/common": "^4.2.4",
"@angular/compiler": "^4.2.4",
"@angular/core": "^4.2.4",
"@angular/forms": "^4.2.4",
"@angular/http": "^4.2.4",
"@angular/platform-browser": "^4.2.4",
"@angular/platform-browser-dynamic": "^4.2.4",
"@angular/router": "^4.2.4",
"angular2-jwt": "^0.2.3",
"chart.js": "^2.7.2",
"core-js": "^2.4.1",
"jquery": "^3.3.1",
"ng2-archwizard": "^2.1.0",
"ng2-charts": "^1.6.0",
"ng2-toastr": "^4.1.2",
"ng2-validation": "^4.2.0",
"ngx-bootstrap": "^2.0.5",
"npm": "^6.2.0",
"rxjs": "^5.4.2",
"slick-carousel": "^1.8.1",
"zone.js": "^0.8.14"
},
"devDependencies": {
"@angular/cli": "^1.7.4",
"@angular/compiler-cli": "^4.2.4",
"@angular/language-service": "^4.2.4",
"@types/c3": "^0.6.0",
"@types/jasmine": "~2.5.53",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
"c3": "^0.6.2",
"codelyzer": "~3.2.0",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0",
"karma": "^2.0.5",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "^5.4.0",
"ts-node": "~3.2.0",
"tslint": "~5.7.0",
"typescript": "~2.3.3"
}
}

谁能帮忙解决这个问题

最佳答案

我想你可以关注这个 tutorial

或者像这样手动更新你的 Angular 包的版本

"@angular/core": "~8.2.4"

像这样更新你的 tsconfig.json

{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "esnext", // add this line
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"target": "es2015",// add this line
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2018",
"dom"
]
}
}

更新:

安装rxjs-compact解决问题

关于javascript - 无法更新 Angular 版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58024132/

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