用于从 Angular 15 升级到 Angular 16 的 Npm 配置

问题描述 投票:0回答:2

我正在尝试从 Angular 15 升级到 Angular 16。

我有版本 15 的配置:

{
  "name": "name",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "watch": "ng build --watch --configuration development",
    "test": "ng test",
    "lint": "ng lint"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^15.0.4",
    "@angular/common": "~15.0.4",
    "@angular/compiler": "~15.0.4",
    "@angular/core": "~15.0.4",
    "@angular/forms": "~15.0.4",
    "@angular/localize": "~15.0.4",
    "@angular/platform-browser": "~15.0.4",
    "@angular/platform-browser-dynamic": "~15.0.4",
    "@angular/router": "~15.0.4",
    "@ng-bootstrap/ng-bootstrap": "^14.0.0",
    "@popperjs/core": "^2.11.6",
    "bootstrap": "^5.2.0",
    "ngx-spinner": "^15.0.1",
    "ngx-toastr": "^15.0.0",
    "rxjs": "~7.5.5",
    "tslib": "^2.4.0",
    "zone.js": "~0.11.5"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^15.0.5",
    "@angular-eslint/builder": "15.1.0",
    "@angular-eslint/eslint-plugin": "15.1.0",
    "@angular-eslint/eslint-plugin-template": "15.1.0",
    "@angular-eslint/schematics": "^15.1.0",
    "@angular-eslint/template-parser": "15.1.0",
    "@angular/cli": "^15.0.5",
    "@angular/compiler-cli": "~15.0.4",
    "@types/jasmine": "~4.0.3",
    "@types/node": "^17.0.30",
    "@typescript-eslint/eslint-plugin": "^5.43.0",
    "@typescript-eslint/parser": "^5.43.0",
    "eslint": "^8.28.0",
    "eslint-plugin-jsdoc": "^39.2.9",
    "jasmine-core": "~4.1.0",
    "karma": "~6.3.19",
    "karma-chrome-launcher": "~3.1.1",
    "karma-coverage": "~2.2.0",
    "karma-jasmine": "~5.0.0",
    "karma-jasmine-html-reporter": "~1.7.0",
    "karma-junit-reporter": "^2.0.1",
    "typescript": "~4.8.4"
   }
 }

这是我第一次尝试新配置(为了运行 Angular 16):

{
  "name": "name",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "test-ci": "ng test --watch=false --browsers=ChromeHeadless",
    "lint": "ng lint"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^15.0.4",
    "@angular/common": "16.0.0",
    "@angular/compiler": "^16.0.0",
    "@angular/core": "16.0.0",
    "@angular/forms": "~15.0.4",
    "@angular/localize": "~15.0.4",
    "@angular/platform-browser": "~15.0.4",
    "@angular/platform-browser-dynamic": "~15.0.4",
    "@angular/router": "~15.0.4",
    "@ng-bootstrap/ng-bootstrap": "^14.0.0",
    "@popperjs/core": "^2.11.6",
    "bootstrap": "^5.2.0",
    "ngx-spinner": "^15.0.1",
    "ngx-toastr": "^15.0.0",
    "rxjs": "~7.5.5",
    "tslib": "^2.4.0",
    "zone.js": "~0.13.1"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "16.0.0",
    "@angular-eslint/builder": "16.0.0",
    "@angular-eslint/eslint-plugin": "16.0.0",
    "@angular-eslint/eslint-plugin-template": "16.0.0",
    "@angular-eslint/schematics": "^16.0.0",
    "@angular-eslint/template-parser": "16.0.0",
    "@angular/cli": "16.0.0",
    "@angular/compiler-cli": "16.0.0",
    "@types/jasmine": "~4.0.3",
    "@types/node": "^18.0.30",
    "@typescript-eslint/eslint-plugin": "^5.43.0",
    "@typescript-eslint/parser": "^5.43.0",
    "eslint": "^8.28.0",
    "eslint-plugin-jsdoc": "^39.2.9",
    "jasmine-core": "~4.1.0",
    "karma": "~6.3.19",
    "karma-chrome-launcher": "~3.1.1",
    "karma-coverage": "~2.2.0",
    "karma-jasmine": "~5.0.0",
    "karma-jasmine-html-reporter": "~1.7.0",
    "karma-junit-reporter": "^2.0.1",
    "typescript": "~4.9.4"
  }
}

但是,这就是我运行“npm install”时得到的结果:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: @angular-devkit/[email protected]
npm ERR! node_modules/@angular-devkit/build-angular
npm ERR!   dev @angular-devkit/build-angular@"16.0.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! dev @angular-devkit/build-angular@"16.0.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: @angular/[email protected]
npm ERR! node_modules/@angular/compiler-cli
npm ERR!   peer @angular/compiler-cli@"^16.0.0" from @angular-devkit/[email protected]
npm ERR!   node_modules/@angular-devkit/build-angular
npm ERR!     dev @angular-devkit/build-angular@"16.0.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

请指导我让它发挥作用。它可以与“--force”一起使用,但我想这不是你想要的。

angular npm-install
2个回答
1
投票

我遵循了 @edjm 的建议,即我安装了一个单独的 Angular 16 应用程序并比较了软件包版本。我使用了新的 Angular 16 安装中提供的版本。

{
  "name": "name",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^16.1.0",
    "@angular/common": "^16.1.0",
    "@angular/compiler": "^16.1.0",
    "@angular/core": "^16.1.0",
    "@angular/forms": "^16.1.0",
    "@angular/platform-browser": "^16.1.0",
    "@angular/platform-browser-dynamic": "^16.1.0",
    "@angular/router": "^16.1.0",
    "@ng-bootstrap/ng-bootstrap": "^15.0.0",
    "rxjs": "~7.8.0",
    "tslib": "^2.3.0",
    "@popperjs/core": "^2.11.6",
    "bootstrap": "^5.2.0",
    "ngx-spinner": "^16.0.2",
    "ngx-toastr": "^15.0.0",
    "zone.js": "^0.13.0"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~16.0.0",
    "@angular-eslint/builder": "~16.0.0",
    "@angular-eslint/eslint-plugin": "~16.0.0",
    "@angular-eslint/eslint-plugin-template": "~16.0.0",
    "@angular-eslint/schematics": "~16.0.0",
    "@angular-eslint/template-parser": "~16.0.0",
    "@angular/cli": "~16.1.2",
    "@angular/compiler-cli": "^16.1.0",
    "@types/jasmine": "~4.0.3",
    "@types/node": "^18.0.30",
    "@typescript-eslint/eslint-plugin": "^5.43.0",
    "@typescript-eslint/parser": "^5.43.0",
    "eslint": "^8.43.0",
    "eslint-plugin-jsdoc": "^46.4.2",
    "jasmine-core": "~4.1.0",
    "karma": "~6.3.19",
    "karma-chrome-launcher": "~3.1.1",
    "karma-coverage": "~2.2.0",
    "karma-jasmine": "~5.0.0",
    "karma-jasmine-html-reporter": "~1.7.0",
    "karma-junit-reporter": "^2.0.1",
    "typescript": "~4.9.4"
  }
}

0
投票

要解决此问题,您可以暂时执行 npm i --legacy-peer-deps 来安装软件包

© www.soinside.com 2019 - 2024. All rights reserved.