React Native - Error while initialising new project

Viewed 2100

I am getting following error when I try to run command

npx react-native init AwesomeProject

npm ERR! code ERESOLVE npm ERR! ERESOLVE could not resolve npm ERR! npm ERR! While resolving: undefined@undefined npm ERR! Found: react-native@0.68.2 npm ERR! node_modules/react-native npm ERR! peer react-native@"*" from @react-native-community/cli@7.0.3 npm ERR!
node_modules/@react-native-community/cli npm ERR!
@react-native-community/cli@"^7.0.3" from react-native@0.68.2 npm ERR! react-native@"0.69.0" from the root project npm ERR! npm ERR! Could not resolve dependency: npm ERR! react-native@"0.69.0" 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.0 npm ERR! node_modules/react-native npm ERR!
react-native@"0.69.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\NIMASHA NAIK\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\NIMASHA NAIK\AppData\Local\npm-cache_logs\2022-06-23T13_40_58_714Z-debug-0.log

Please can anyone help?

Thank You.

5 Answers

Removing the ~/.npm cache folder worked for me

rm -r ~/.npm

I had the same problem so I did it

npm config set legacy-peer-deps true
npx react-native

try it worked.

npm add react-native@0.69.0

Run this command to upgrade react-native. Hope it works.

Are you able to post the full log found in your AppData?

You could also try completely removing node.js from your system and try reinstalling it again.

https://nodejs.org/en/

Install the LTS version and try this again. Also make sure npm and npx are both working in your working directory PATH.

This is an issue in node which is caused by white space in user name between first-name and last-name in windows.

run the following command after replacing firstname with your windows user firstname in command prompt with administrator access

npm config set cache "C:\Users\Firstname~1\AppData\Roaming\npm-cache" --global

Related