簡體   English   中英

在需要版本沖突的項目中如何正確解決NPM依賴?

[英]How do you properly resolve NPM dependencies in projects that require conflicting versions?

我正在嘗試使用此處的說明為react-native-navigation構建 playground 應用程序。 一個簡單的npm install失敗,因為對等依賴項有react: "*"react-native: "*" ,所以今天(2021 年 1 月)NPM 嘗試安裝react@17.0.1 ,但也嘗試安裝react-native@0.63.4 ,這需要react@16.13.1 我收到以下錯誤:

npm ERR! While resolving: react-native-navigation@7.7.0
npm ERR! Found: react@17.0.1
npm ERR! node_modules/react
npm ERR!   peer react@"*" from the root project
...
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"16.13.1" from react-native@0.63.4
npm ERR! node_modules/react-native
npm ERR!   peer react-native@"*" from the root project
npm ERR!   peer react-native@">=0.59" from @react-native-community/datetimepicker@2.6.2
npm ERR!   node_modules/@react-native-community/datetimepicker
npm ERR!

然后我嘗試通過在我的根項目中安裝react@16.13.1來解決這個問題,希望 NPM 會檢測到該版本並將其用作對等依賴項,但結果卻是@react-native-community/datetimepicker@2.6.2依賴在react-native-windows@^0.6.20上,它取決於react@16.11.0 ,而是給我這個錯誤:

npm ERR! Found: react@16.13.1
npm ERR! node_modules/react
npm ERR!   dev react@"16.13.1" from the root project
...
npm ERR! Could not resolve dependency:
npm ERR! peer react@"16.11.0" from react-native-windows@0.62.20
npm ERR! node_modules/@react-native-community/datetimepicker/node_modules/react-native-windows
npm ERR!   optional react-native-windows@"^0.62.0-0" from @react-native-community/datetimepicker@2.6.2
npm ERR!   node_modules/@react-native-community/datetimepicker
npm ERR!     dev @react-native-community/datetimepicker@"^2.5.0" from the root project
npm ERR!     1 more (react-native-ui-lib)
npm ERR!

我如何弄清楚這個問題? 我期待一切都能與npm install一起使用。 安裝項目的正確方法是什么,或者在啟動項目之前必須不斷調試依賴沖突是否很常見?

事實證明,我使用的節點 15.0.x 顯然太新了。 降級到 14.15.1 有效。

嘗試執行 npm install --legacy-peer-deps

我也在使用節點 15.0.x。 降級到 14.xx 有效。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM