Recently, I faced an unexpected react native error. I was creating a new React Native project with the command npx react-native init and I was shown an undefined@undefined error in the terminal. Following is the complete error.
npm ERR! code ERESOLVE npm ERR! ERESOLVE could not resolve npm ERR! npm ERR! While resolving: undefined@undefined npm ERR! Found: firstname.lastname@example.org npm ERR! node_modules/react-native npm ERR! peer react-native@"*" from @email@example.com npm ERR! node_modules/@react-native-community/cli npm ERR! @react-native-community/cli@"^6.0.0" from firstname.lastname@example.org npm ERR! react-native@"0.69.4" from the root project npm ERR! npm ERR! Could not resolve dependency: npm ERR! react-native@"0.69.4" from the root project npm ERR! npm ERR! Conflicting peer dependency: email@example.com npm ERR! node_modules/react npm ERR! peer react@"18.0.0" from firstname.lastname@example.org npm ERR! node_modules/react-native npm ERR! react-native@"0.69.4" 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 /Users/mohammedrashid/.npm/eresolve-report.txt for a full report.
Following is the solution for this react native error.
- Go to users/YourName/ folder.
- Unhide the hidden folders. If you are on Mac then press Cmd + Shift + . (command + shift + dot)
- Now open .npm folder.
- Delete folders named _cacache, _logs, and _npx.
- That’s it. Now open and rerun the command. The error will be gone this time.
I hope this react native error fix is helpful for you.