React-Native/Error

[React-Native][Error] npm ERR! code ERESOLVE

TrueSik 2022. 11. 17. 00:50

npm install Error

가끔씩 잘 되던 npm install이 갑자기 error가 발생하는 경우가 있었을 것이다.

 

원인

- dependencies 버전 문제

- node와 npm 버젼이 맞지 않는 경우

- npm 7 버전으로 인한 경우

(이전의 npm 버전에서는 peer dependencies가 있으면 경고는 뜨지만 설치는 되었으나, npm 7 버전은 설치가 안됨)

 

 

해결 방법

npm install --force
OR
npm install --legacy-peer-deps

npm install [라이브러리] --force
OR
npm install [라이브러리] --legacy-peer-deps

 

차이

--force : package-lock.json에 몇 가지의 다른 의존 버전들을 추가 ( 에러를 우회함 )

 

--legacy-peer-deps : peerDependency가 맞지 않아도 일단 설치 ( 에러를 무시함 )

 

참고

https://stackoverflow.com/questions/66020820/npm-when-to-use-force-and-legacy-peer-deps

 

npm: When to use `--force` and `--legacy-peer-deps`

I'm new to npm and am trying to understand how recreating the node_modules directory for deployment works. We're using npm ci instead of npm install to ensure a clean slate during deployment. Howev...

stackoverflow.com

https://github.blog/2021-02-02-npm-7-is-now-generally-available/

 

npm 7 is now generally available! | The GitHub Blog

We’re announcing version 7 of the npm CLI is now generally available.

github.blog