npm ERR! Conflicting peer dependency: react@18.0.0

Viewed 3221

I can't seem to understand why this error is happening. I am trying to create a new react-native project with another already created and in a different directory which is not lower in the directory tree than the other installation. I have uninstalled and reinstalled the node which I thought might be the issue. I used brew doctor and removed a previous install of homebrew which I had in usr/local/includes

I'm trying to get a clean install of React-native but It appears I can't do so.

Thank you for any help.

This is the error I keep getting

npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: undefined@undefined
npm ERR! Found: react-native@0.67.4
npm ERR! node_modules/react-native
npm ERR!   peer react-native@"*" from @react-native-community/cli@6.4.0
npm ERR!   node_modules/@react-native-community/cli
npm ERR!     @react-native-community/cli@"^6.0.0" from react-native@0.67.4
npm ERR!   react-native@"0.69.1" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! react-native@"0.69.1" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: react@18.0.0
npm ERR! node_modules/react
npm ERR!   peer react@"18.0.0" from react-native@0.69.1
npm ERR!   node_modules/react-native
npm ERR!     react-native@"0.69.1" 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/Name/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/Name/.npm/_logs/2022-07-14T06_15_09_791Z-debug-0.log
3 Answers

I have the same issue as yours. To fix the error.

Open cli then type: open /Users/Name/.npm then delete folders _cacache, _logs, _npx.

After deleting those folders I'm able to install new React Native project.

Add --legacy-peer-deps to the end of the command

--legacy-peer-deps

Step 1: open /Users/Name/.npm

Step 2: To view hidden folders on Mac press Cmd + Shift + .(dot)

Step 3: Delete folders _cacache, _logs, _npx

/Users/Name/.npm

Related