我在 React Js 中做過多次,但這是我第一次在 React Native 中使用 axios。當我通過npm install axios它安裝 axios 時,會出現與其他庫相關的巨大日志錯誤。
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: react-native-location-view@0.3.0
npm ERR! Found: react-native-vector-icons@8.1.0
npm ERR! node_modules/react-native-vector-icons
npm ERR! peer react-native-vector-icons@">7.0.0" from react-native-elements@3.4.2
npm ERR! node_modules/react-native-elements
npm ERR! react-native-elements@"^3.4.2" from the root project
npm ERR! peer react-native-vector-icons@"*" from react-native-paper@4.9.2
npm ERR! node_modules/react-native-paper
npm ERR! react-native-paper@"^4.9.2" from the root project
npm ERR! 1 more (the root project)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react-native-vector-icons@"^4.4.3" from react-native-location-view@0.3.0
npm ERR! node_modules/react-native-location-view
npm ERR! react-native-location-view@"^0.3.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: react-native-vector-icons@4.6.0
npm ERR! node_modules/react-native-vector-icons
npm ERR! peer react-native-vector-icons@"^4.4.3" from react-native-location-view@0.3.0
npm ERR! node_modules/react-native-location-view
npm ERR! react-native-location-view@"^0.3.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\Suyash\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\Suyash\AppData\Local\npm-cache\_logs\2021-12-07T15_22_51_263Z-debug.log
它應該與 React JS 相同,但由于某種原因出現了這些錯誤。
uj5u.com熱心網友回復:
這不是 Axios 的問題,您的依賴項沖突,因為它們已過時。例如:
Could not resolve dependency:
npm ERR! peer react-native-vector-icons@"^4.4.3" from react-native-location-view@0.3.0
它試圖拉取第 4 版,而React Native Vector Icons是第 9 版。您應該更新您的依賴項并相應地檢查任何沖突的代碼。還建議將 Yarn 與 React Native 一起使用。
您可以在終端中運行:
rm node_modules && rm package-lock.json && yarn install
如果你安裝了Yarn。如果如您所說,一切正常,您可以嘗試:
npm i react-native-location-view --legacy-peer-deps
或者:
npm i --legacy-peer-deps
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/379016.html
上一篇:npm錯誤!無效的選項引數
