#angular #angular-upgrade
Вопрос:
У меня есть приложение Angular 12, которое я пытаюсь обновить до angular 13.
Согласно https://update.angular.io/?l=2amp;v=12.0-13.0 Я должен бежать:
npx @angular/cli@13 update @angular/core@13 @angular/cli@13
Но когда я это делаю, я получаю следующую ошибку:
npx @angular/cli@13 update @angular/core@13 @angular/cli@13
The installed local Angular CLI version is older than the latest stable version.
Installing a temporary version to perform the update.
✔ Package successfully installed.
Using package manager: 'npm'
Collecting installed dependencies...
Found 38 dependencies.
Fetching dependency metadata from registry...
Updating package.json with dependency @angular-devkit/build-angular @ "13.0.2" (was "12.1.1")...
Updating package.json with dependency @angular/cli @ "13.0.2" (was "12.1.1")...
Updating package.json with dependency @angular/compiler-cli @ "13.0.1" (was "12.1.1")...
Updating package.json with dependency typescript @ "4.4.4" (was "4.3.5")...
Updating package.json with dependency @angular/animations @ "13.0.1" (was "12.1.1")...
Updating package.json with dependency @angular/common @ "13.0.1" (was "12.1.1")...
Updating package.json with dependency @angular/compiler @ "13.0.1" (was "12.1.1")...
Updating package.json with dependency @angular/core @ "13.0.1" (was "12.1.1")...
Updating package.json with dependency @angular/forms @ "13.0.1" (was "12.1.1")...
Updating package.json with dependency @angular/platform-browser @ "13.0.1" (was "12.1.1")...
Updating package.json with dependency @angular/platform-browser-dynamic @ "13.0.1" (was "12.1.1")...
Updating package.json with dependency @angular/router @ "13.0.1" (was "12.1.1")...
UPDATE package.json (1566 bytes)
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: scrum-poker-app@0.0.0
npm ERR! Found: @angular-devkit/build-angular@12.1.1
npm ERR! node_modules/@angular-devkit/build-angular
npm ERR! dev @angular-devkit/build-angular@"~13.0.2" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! dev @angular-devkit/build-angular@"~13.0.2" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: @angular/compiler-cli@13.0.1
npm ERR! node_modules/@angular/compiler-cli
npm ERR! peer @angular/compiler-cli@"^13.0.0" from @angular-devkit/build-angular@13.0.2
npm ERR! node_modules/@angular-devkit/build-angular
npm ERR! dev @angular-devkit/build-angular@"~13.0.2" 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.
npm ERR!
✖ Package install failed, see above.
Я также пробовал с --force
флагом, он работает, но затем, когда я делаю npm install
, я получаю это:
npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: scrum-poker-app@0.0.0
npm ERR! Found: @angular-devkit/build-angular@12.1.1
npm ERR! node_modules/@angular-devkit/build-angular
npm ERR! dev @angular-devkit/build-angular@"~13.0.2" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! dev @angular-devkit/build-angular@"~13.0.2" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: @angular/compiler-cli@13.0.1
npm ERR! node_modules/@angular/compiler-cli
npm ERR! peer @angular/compiler-cli@"^13.0.0" from @angular-devkit/build-angular@13.0.2
npm ERR! node_modules/@angular-devkit/build-angular
npm ERR! dev @angular-devkit/build-angular@"~13.0.2" 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.
Есть идеи, чего мне не хватает?
ОТРЕДАКТИРУЙТЕ мой текущий package.json
{
"name": "scrum-poker-app",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test"
},
"private": true,
"dependencies": {
"@angular/animations": "~12.1.0",
"@angular/cdk": "^12.1.1",
"@angular/common": "~12.1.0",
"@angular/compiler": "~12.1.0",
"@angular/core": "~12.1.0",
"@angular/fire": "^6.1.5",
"@angular/forms": "~12.1.0",
"@angular/platform-browser": "~12.1.0",
"@angular/platform-browser-dynamic": "~12.1.0",
"@angular/router": "~12.1.0",
"@datorama/akita": "^6.2.0",
"@datorama/akita-ng-router-store": "^6.0.0",
"@firebase/firestore-types": "^2.3.0",
"akita-ng-fire": "^6.0.0",
"date-fns": "^2.22.1",
"firebase": "^8.7.0",
"firebaseui": "^4.8.0",
"firebaseui-angular": "^5.1.3",
"ngx-date-fns": "^8.1.0",
"primeflex": "^2.0.0",
"primeicons": "^4.1.0",
"primeng": "^12.0.0",
"rxjs": "~6.6.0",
"tslib": "^2.2.0",
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "~12.1.0",
"@angular/cli": "~12.1.0",
"@angular/compiler-cli": "~12.1.0",
"@datorama/akita-ngdevtools": "^6.0.0",
"@types/jasmine": "~3.6.0",
"@types/node": "^12.11.1",
"jasmine-core": "~3.7.0",
"karma": "~6.3.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.0.3",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"typescript": "~4.3.2"
}
}
Комментарии:
1. пожалуйста, предоставьте свой
package.json
файл2. @AlexElin Я добавил это, извините
3. не могли бы вы также предоставить свою
npm
версию? Я вижу, что были проблемы с npm 7 github.com/angular/angular-cli/issues/19957 . Может быть, они как-то связаны с вашим случаем4. @AlexElin NPM 8.1.0
5. @Vega Как я уже упоминал, я попробовал принудительный вариант, не помогло
Ответ №1:
похоже, проблема с npm
у меня есть «npm —version» —> 8.5.4, но упоминается, что версия 7.x выдает ту же ошибку
эта проблема рассматривается здесь: https://github.com/angular/angular-cli/issues/21204
предлагаемые обходные пути:
- передача опции —force в ng update, которая распространит флаг force на npm.
- Понижение до npm 6
- Переключитесь на yarn в качестве менеджера пакетов
я использовал первый:
npm i
npx @angular/cli@13 update @angular/core@13 @angular/cli@13 --force
Ответ №2:
Здесь та же проблема. Я смог перейти с angular 12 на angular 13.2 только после того, как я выполнил npm install
.
npm i
npx @angular/cli@13 update @angular/core@13 @angular/cli@13