The error “npm ERR! Conflicting peer dependency: react@18.0.0” is an error that is invoked whenever you are coding in react-native and trying to create a project. Given below is the snippet of the error:
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
I would like to share with you the steps I took to fix the “npm ERR! Conflicting peer dependency: react@18.0.0” in project file.
Why “npm ERR Conflicting peer dependency react@18.0.0” error is seen?
The error, “npm ERR! Conflicting peer dependency: react@18.0.0” is seen because; you must not have added the following command –legacy-peer-deps to the end of your code. The error is also seen because of corrupted folders like _cacache, _logs, _npx.
The detailed solution to fix the error “npm ERR! Conflicting peer dependency: react@18.0.0”, is given below:
How to fix “npm ERR Conflicting peer dependency react@18.0.0” Error?
To fix the error, you will have to add the following command “–legacy-peer-deps” to the end of your code. If the error is not fixed you have to delete your corrupted folders like _cacache, _logs, _npx.
To fix the error, “npm ERR! Conflicting peer dependency: react@18.0.0”, follow one of the below-mentioned methods:
Method 1: Add the code
To fix the error, “npm ERR! Conflicting peer dependency: react@18.0.0”, you will have to add the following command –legacy-peer-deps to the end of your code. The code which you will have to add is as given below:
--legacy-peer-deps
This should fix the error, “npm ERR! Conflicting peer dependency: react@18.0.0”.
Method 2: Deleting easily Corrupted Folders
To fix the error, “npm ERR! Conflicting peer dependency: react@18.0.0”, you will have to open your cli then type the following address : open /Users/Name/.npm
. Here you will find the folders of _cacache, _logs, _npx, you will have to delete them as these are easily corrupted and are known to cause errors.
After deleting the above-shown folders you will now be able to install new React Native project.
This should fix the error, “npm ERR! Conflicting peer dependency: react@18.0.0”.
Conclusion
To fix the error “gypgyp ERR!ERR! find VSfind VS msvs_version not set from command line or npm config”, you will have to add the following command –legacy-peer-deps to the end of your code. If the error is not fixed you will have to delete your corrupted folders like _cacache, _logs, _npx