I have done in React Js multiple times but it is my first time using axios in React Native. When I install axios through npm install axios
it gives a huge log error related to other libraries .
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
It should have been same as React JS but for some reason these errors are appearing.
CodePudding user response:
This isn't an issue with Axios your dependencies are conflicting because they're out-dated. For example:
Could not resolve dependency:
npm ERR! peer react-native-vector-icons@"^4.4.3" from react-native-location-view@0.3.0
which is trying to pull version 4 and React Native Vector Icons is on version 9. You should update your dependencies and check for any conflicting code accordingly. Would also suggest using Yarn with React Native.
You can run in the terminal:
rm node_modules && rm package-lock.json && yarn install
if you have Yarn installed. If as you stated everything works correctly you could try:
npm i react-native-location-view --legacy-peer-deps
or:
npm i --legacy-peer-deps