使用 Angular CLI v13.1.0 創建新專案時出現以下錯誤
\ Installing packages (npm)...npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: example-app@0.0.0
npm ERR! Found: typescript@4.5.3
npm ERR! node_modules/typescript
npm ERR! dev typescript@"~4.5.2" from the root project
npm ERR! peer typescript@">=4.4.3 <4.6" from @angular-devkit/build-angular@13.1.0
npm ERR! node_modules/@angular-devkit/build-angular
npm ERR! dev @angular-devkit/build-angular@"~13.1.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer typescript@">=4.4.2 <4.5" from @angular/compiler-cli@13.0.3
npm ERR! node_modules/@angular/compiler-cli
npm ERR! dev @angular/compiler-cli@"~13.0.0" from the root project
npm ERR! peer @angular/compiler-cli@"^13.0.0 || ^13.1.0-next" from @angular-devkit/build-angular@13.1.0
npm ERR! node_modules/@angular-devkit/build-angular
npm ERR! dev @angular-devkit/build-angular@"~13.1.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.
npm ERR!
npm ERR! See C:\Users\user\AppData\Local\npm-cache\eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\user\AppData\Local\npm-cache\_logs\2021-12-10T12_46_21_814Z-debug.log
× Package install failed, see above.
The Schematic workflow failed. See above.
我使用的Node JS版本16.13.1和npm版本8.1.2
我嘗試使用 --force 清除 npm 快取,還重新安裝了 Node JS。仍然沒有運氣。
uj5u.com熱心網友回復:
所以我是這樣解決的:
我使用
ng new. 然后它創建了專案,但在安裝依賴項時拋出錯誤。然后我手動編輯了該
package.json檔案并將所有 angular 包版本替換13.0.0為13.1.0并運行npm i.
之后,所有軟體包都安裝得很好,我可以運行ng serve.
uj5u.com熱心網友回復:
這只是一個正在跟蹤的 TypeScript 補丁版本問題:https : //github.com/angular/angular-cli/issues/22333,所以只需降級或npm i --force直到他們修復它。
uj5u.com熱心網友回復:
走這條路
C:\Users\user\AppData\Local
并洗掉此檔案夾。
npm快取
然后測驗一下。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/381331.html
