I’m following the setup instructions from the React Native Documentation page, on my M1 Macbook Pro. I have previously worked on React projects and was able to create and run React Native Expo projects previously on the same machine.
I followed the instructions to the letter, but when I arrived at the ‘Create A New Application" section, using the npx react-native init AwesomeProject
command, the new project creation failed. Here are the error message outputted on the Terminal:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: undefined@undefined
npm ERR! Found: [email protected]
npm ERR! node_modules/react-native
npm ERR! peer react-native@"*" from @react-native-community/[email protected]
npm ERR! node_modules/@react-native-community/cli
npm ERR! @react-native-community/cli@"^6.0.0" from [email protected]
npm ERR! react-native@"0.69.2" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! react-native@"0.69.2" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/react
npm ERR! peer react@"18.0.0" from [email protected]
npm ERR! node_modules/react-native
npm ERR! react-native@"0.69.2" 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.
I tried to uninstall react-native and install it back but couldn’t find a proper instruction on the net to do that. How can I just scrape the previously installed react-native (judging from the error message, i got [email protected], when I want to use the latest RN) and install a fresh, latest react native?
3
Answers
if you are on Mac and your node version is 18.. which Is latest but not greatest.. you need to download 16.. the stable one.
Step-1
Step 2 – and install it from node site by downloading the binary
Step 3 – just check the node version again if you have 16..
then you can try creating the react native project once again.
Please let us know if it worked for you. Wish you luck!!
In addition to what the answer suggests, you can do
brew install node@16
to install this particular version instead of manually downloading the binary.If installing node version 16 doesn’t work for you ensure you update npm by running
sudo npm update -g
.