삽질기록

오늘의 에러 - next-auth, Module not found: Can't resolve 'next-auth/react'

Deeb 2022. 9. 26. 14:58

문제 상황

Module not found: Can't resolve 'next-auth/react'

1차 해결법

npm i 를 해도 설치가 진행되지 않고 에러가 발생했고 아래와 같이 문구가 떴다. 

 

Found: next@12.2.0

next@"12.2.0" from the root project

Fix the upstream dependency conflict, or retry
this command with --force, or --legacy-peer-deps
to accept an incorrect (and potentially broken) dependency resolution.

 

라고 친절하게 해결 방법을 알려주었다.

 

여기서 궁금해진것은 --force와 --legacy-peer-deps의 차이는 무엇일까?

--force를 사용하여 충돌을 우회하거나
--legacy-peer-deps 명령을 사용하여 피어 종속성을 완전히 무시할 수 있는 옵션이 있다(이 동작은 버전 4-6과 유사함)

--force 는 충돌하는 peerDependencies가 루트 프로젝트에 설치하고
--legacy-peer-deps 는 peerDependencies가 자동으로 설치 되는 기능을 무시한다.
블로그 글을 보면 대부분 --legacy-peer-deps를 사용하는 것 같은데, --force가 더 낫다는 의견이 많다고 한다.

 

나의 해결 방법

npm i --force 로 설치하여 버전 충돌을 해결하였다.

 

 

참고 내용

https://jane-aeiou.tistory.com/79

 

[Node.js] npm install --force 와 --lagacy-peer-deps 차이

npm install --force 와 npm install --lagacy-peer-deps 차이 npm install 에러 github actions 로 자동배포를 설정해뒀는데, 배포가 되지않아 확인해봤더니 npm install 에서 unable to resolve dependency t..

jane-aeiou.tistory.com

 

반응형