我正在嘗試安裝ngx-cookie包,以便我可以在我的應用程式中使用 CookieService。但是,我收到以下依賴項沖突:
$ npm install ngx-cookie --save
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: @angular/[email protected]
npm ERR! node_modules/@angular/core
npm ERR! @angular/core@"~13.0.0" from the root project
npm ERR! peer @angular/core@">9.0.0" from [email protected]
npm ERR! node_modules/ngx-cookie
npm ERR! ngx-cookie@"*" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/core@"13.1.1" from @angular/[email protected]
npm ERR! node_modules/@angular/common
npm ERR! peer @angular/common@">9.0.0" from [email protected]
npm ERR! node_modules/ngx-cookie
npm ERR! ngx-cookie@"*" 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.
我嘗試安裝ngx-cookie-service但我遇到了同樣的錯誤。
我是什么做的?Angular 版本有問題嗎?
uj5u.com熱心網友回復:
這不是角度問題。它更多地與 npm7 版本有關。
在之前版本的 npm (4-6) 中,對等依賴沖突會顯示版本不兼容的警告,但仍會安裝依賴項而不會出錯。如果存在無法自動解決的上游依賴沖突,npm 7 將阻止安裝。
理想情況下,您不應像 ngx-cookie 包中那樣出現此錯誤,角度對等點定義為 > 這意味著它將與所有大于 9 的 angular 版本兼容。
正如錯誤日志中所建議的那樣,您可以使用 --force 標志或 --legacy-peer-deps(此行為類似于版本 4-6)。
參考:- https://github.blog/2021-02-02-npm-7-is-now-generally-available/
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/402117.html
