크로스 플랫폼/React-Native <JSX>

[React-Native] ERESOLVE While resolving: undefined@undefined 에러 해결하기

TaeGyeong Lee 2023. 7. 20. 16:51

발생 에러

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.72.3" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! react-native@"0.72.3" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: react@18.2.0
npm ERR! node_modules/react
npm ERR!   peer react@"18.2.0" from react-native@0.72.3
npm ERR!   node_modules/react-native
npm ERR!     react-native@"0.72.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.

 

해결 방법

먼저 위 에러 로그와 상황이 비슷한 지 다시 한번 확인해 주세요. 위 에러 로그를 통해 설치된 @react-native-community/cli 의 버전(6.4.0)이 생성하려는 react-native 버전(0.72.3)과 호환되지 않아 발생하는 문제임을 확인하실 수 있어야 합니다.

react-native 프로젝트가 최신 버전일 경우 아래 명령을 통해 cli 를 최신 버전을 업데이트해 주세요.

npm install -g @react-native-community/cli

만약 react-native 프로젝트가 구버전일 경우 이에 맞는 cli 버전을 찾아 설치해 주세요.