作為一個devDependency,我安裝了"@typescript-eslint/parser"。"~4.31.2"
運行npm install告訴我,一個包需要4.20.0,另一個包需要4.28.3--如果我對這個錯誤理解正確的話。
我如何處理這些npm包的沖突?
npm ERR! 在解決的時候。@nrwl/[email protected]
npm ERR! 發現。@typescript-eslint/[email protected]
npm ERR!node_modules/@typescript-eslint/parser
npm ERR! dev @typescript-eslint/parser@"~4.31.2" from the root project
npm ERR! @typescript-eslint/parser@"^4.20.0" 來自[email protected]
npm ERR!node_modules/eslint-config-next
npm ERR!dev eslint-config-next@"11.1.2" from the root project
npm ERR! eslint-config-next@"^11.1.0" from @nrwl/[email protected]
npm ERR!node_modules/@nrwl/next
npm ERR! dev @nrwl/next@"12.9.0" from the root project
npm ERR! 1 more (@typescript-eslint/eslint-plugin)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @typescript-eslint/parser@"~4.28.3" from @nrwl/[email protected]
npm ERR!node_modules/@nrwl/eslint-plugin-nx
npm ERR!dev @nrwl/eslint-plugin-nx@"12.9.0" from the root project
npm ERR!
npm ERR! 與同行的依賴關系相沖突。@typescript-eslint/[email protected]
npm ERR! node_modules/@typescript-eslint/parser
npm ERR! peer @typescript-eslint/parser@"~4.28.3" from @nrwl/[email protected]
npm ERR!node_modules/@nrwl/eslint-plugin-nx
npm ERR!dev @nrwl/eslint-plugin-nx@"12.9.0" from the root project
uj5u.com熱心網友回復:
你使用的是npm7.x,它比npm6.x對同行的依賴更加嚴格。最簡單的解決方案是運行npm install并加上--legacy-peer-deps標志。從理論上講,這可能會導致一些與同行依賴關系不兼容的問題。在實踐中,很多人還是會這樣做。而且很多人都在運行npm6.x,這是那里的默認行為,所以很多人都在這樣做,也許根本沒有意識到這一點。
在你的例子中,@nrwl/[email protected]說它需要@typescript-eslint/[email protected]而你正在安裝@typescript-eslint/[email protected]。因此,如果你不想使用npm6.x或--legacy-peer-deps解決方案,另一種可能性是安裝@typescript-eslint/[email protected]而不是4.31.2.
你可以做的另一件事是打開一個拉動請求,以更新@nrwl/eslint-plugin-nx,在相關的peerDependencies條目中使用^而不是~。這將允許4.x的同行依賴,而不是限制在4.28.x。(我去看了一下,但是在那個倉庫里有幾百個問題,所以我沒有花時間去看。)
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/331043.html
標籤:
