我正在按照角度更新指南更新我的角度應用程式,但我遇到了對等依賴項的錯誤。
首先,我從 angular 8 更新到 9,但仍然存在對等依賴錯誤。所以我將此命令與--force引數一起使用:
cmd /C "set "NG_DISABLE_VERSION_CHECK=1" && npx @angular/cli@9 update @angular/cli@9 @angular/core@9" --force
它有效!
然后從 Angular 9 到 10,使用相同的方法
npx @angular/cli@10 update @angular/core@10 @angular/cli@10 --force
它也有效。現在我想繼續使用 Angular 11、12 和 13,但是當我使用這個命令時:
npx @angular/cli@11 update @angular/core@11 @angular/cli@11 --force
我收到此錯誤:
安裝的 Angular CLI 版本已過時。
安裝臨時 Angular CLI 版本 11.2.18 來執行更新。
通過 npm 安裝工具包。
通過 npm 安裝工具包。
使用包管理器:'npm'
收集已安裝的依賴項...
找到 61 個依賴項。
從注冊表獲取依賴元資料...
包“@swimlane/ngx-charts”與“@angular/animations”有不兼容的對等依賴(需要“7.x || 8.x”(擴展),將安裝“11.2. 14 英寸)。
包“@ng-bootstrap/ng-bootstrap”對“@angular/forms”有不兼容的對等依賴(需要“^8.0.0”(擴展),將安裝“11.2.14”)。
包“@swimlane/ngx-charts”對“@angular/platform-b??rowser”有不兼容的對等依賴(需要“7.x || 8.x”(擴展),將安裝“11.2.14”)。
包“@swimlane/ngx-charts”對“@angular/platform-b??rowser-dynamic”有不兼容的對等依賴(需要“7.x || 8.x”(擴展),將安裝“11.2.14”)。
更新 package.json 依賴 @angular-devkit/build-angular @ "0.1102.18" (原為 "0.1002.4")...
更新 package.json 依賴 @angular/cli @ "11.2.18" (原為 " 10.2.4")...
更新 package.json 依賴 @angular/compiler-cli @ "11.2.14" (原為 "10.2.5")...
更新包。
更新 package.json 依賴 @angular/animations @ "11.2.14" (原為 "10.2.5")...
更新 package.json 依賴 @angular/common @ "11.2.14" (原為 "10.2.5" )...
更新 package.json 依賴 @angular/compiler @ "11.2.14" (原為 "10.2.5")...
更新 package.json 依賴 @angular/core @ "11.2.14" (原為 " 10.2.5")...
更新 package.json 依賴 @angular/forms @ "11.2.14" (原為 "10.2.5")...
更新 package.json 依賴 @angular/platform-b??rowser @ "11.2 .14" (原為 "10.2.5")...
更新 package.json 依賴 @angular/platform-b??rowser-dynamic @"11.2.14" (原為 "10.2.5")...
使用依賴項 @angular/router @“11.2.14”(原為“10.2.5”)更新 package.json...
更新 package.json(2808 位元組)
? 安裝包 (npm)...npm 錯誤!代碼 ERESOLVE
npm 錯誤!ERESOLVE 無法決議
npm ERR!
npm 錯誤!解決時:[email protected]
npm ERR!發現:@angular-devkit/[email protected]
npm ERR!node_modules/@angular-devkit/build-angular
npm 錯誤!dev @angular-devkit/build-angular@"~0.1102.18" 來自根專案
npm ERR!
npm 錯誤!無法解決依賴關系:
npm ERR!dev @angular-devkit/build-angular@"~0.1102.18" 來自根專案
npm ERR!
npm 錯誤!沖突的對等依賴:@angular/[email protected]
npm ERR!node_modules/@angular/compiler-cli
npm 錯誤!來自@angular-devkit/[email protected]
npm 錯誤的對等 @angular/compiler-cli@"^11.0.0 || ^11.2.0-next"!node_modules/@angular-devkit/build-angular
npm 錯誤!dev @angular-devkit/build-angular@"~0.1102.18" 來自根專案
npm ERR!
npm 錯誤!修復上游依賴沖突,或者重試
npm ERR!此命令帶有 --force 或 --legacy-peer-deps
npm ERR!接受不正確的(并且可能被破壞的)依賴解決方案。
npm 錯誤!
npm 錯誤!有關完整報告,請參閱 C:\Users\leino\AppData\Local\npm-cache\eresolve-report.txt。npm 錯誤!可以在以下位置找到此運行的完整日志:
npm ERR!C:\Users\leino\AppData\Local\npm-cache_logs\2022-01-14T16_41_50_262Z-debug.log? Package install failed, see above.
× Migration failed. See above for further details.
I know that was a bad idea to use --force argument, but prefer to solve peer dependencies once angular is updated, not on each version.
Please, does anyone got an idea ?
uj5u.com熱心網友回復:
從8升級到13!這就是我會做的!
卸載全域
@angular/cli使用
sudo npm uninstall -g @angular/cli使用安裝最新的全球版本的 Angular cli
sudo npm install -g @angular/cli使用檢查安裝的全域版本
sudo npm list -g depth0使用創建新專案
sudo ng new yourProjectName洗掉
node_modules檔案夾和package-lock.json file移動舊專案檔案(不要覆寫
angular.json或package.json歸檔,而是將非角度 npm 包從舊專案移動package.json到新專案package.json檔案)跑
sudo npm install運行
ng serve和運行您的應用程式錯誤
祝你好運
uj5u.com熱心網友回復:
我今天遇到了完全相同的問題。這就是我修復它的方法:
npx @angular/cli@11 update @angular/core@11 @angular/cli@11 --force
# now getting the same errors as above
npm install @angular-devkit/build-angular@~0.1102.18 --force
git checkout -- .
npx @angular/cli@11 update @angular/core@11 @angular/cli@11 --force
現在轉到 package.json 并洗掉包含@angular-devkit/build-ng-packagr.
執行
npm install
完畢
也許從 package.json plus 中洗掉該特定行npm install就足夠了,上面的其他命令是不必要的,但我寧愿告訴你我所做的一切:)
順便說一句,在我嘗試所有這些之前,我還按照上述評論之一的建議降級到 npm v7,但我認為這沒有必要或沒有任何幫助。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/412057.html
標籤:
