1

I want to create a new react-native app using react-native cli, so I used the command npx react-native init newApp according to the documentation at https://reactnative.dev/docs/environment-setup. While executing this I am getting npm error logs as follows:

PS D:\Android development> npx react-native init newApp                        
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
Need to install the following packages:
  [email protected]
Ok to proceed? (y) y
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@"^7.0.3" from [email protected]
npm ERR!   react-native@"0.70.3" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! react-native@"0.70.3" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/react
npm ERR!   peer react@"18.1.0" from [email protected]
npm ERR!   node_modules/react-native
npm ERR!     react-native@"0.70.3" 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\abhad\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\abhad\AppData\Local\npm-cache\_logs\2022-10-13T07_58_54_900Z-debug-0.log

Can anyone solve this? Please suggest a solution.

1 Answer 1

7

I just fixed this issue. Looks like its a problem with npm.

I just ran npm config set legacy-peer-deps true before running npx react-native init newApp (according to https://github.com/facebook/react-native/issues/34051) and this fixed all!

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you. It helped. But you need to run another command today: npx @react-native-community/cli init

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.