React

[react] create-react-app webpack 버전 오류 발생할 때

joy_lee 2022. 1. 12. 22:00

"webpack"의 버전이 맞지 않는다며 아예 프로젝트가 실행되지 않는 경우가 있다.

 


The react-scripts package provided by Create React App requires a dependency:

  "webpack": "4.41.5"

Don't try to install it manually: your package manager does it automatically.
However, a different version of webpack was detected higher up in the tree:


콘솔에 나온 대로 여러가지 방법을 사용해봤지만 해결이 안됐다. 그러던 중 인터넷에서 다른 사람이 해결했다는 것을 보고 따라했는데 해결됐다.

 

내가 생성한 프로젝트보다 상위 경로에 있는 node_modules 폴더를 삭제하면 된다!

 

내 경우는 C:\Users/node_modules 가 있었다. 왜 여기에 있는지는 잘 모르겠지만 삭제하고 다시 실행하니 잘 됐다.

 

이 에러 고친다고 프로젝트 폴더 내의 node_modules 폴더를 몇 번 삭제하고 다시 install했는지 모르겠다. 그래도 잘 해결해서 다행이고 다음에 같은 이유로 실행되지 않는다면 이 글을 참고하기 위해 남긴다.

 

참고한 사이트

https://letsgojieun.tistory.com/104?category=891751 

 

CRA 리액트 웹팩 버전 안 맞는 에러 : npm start 안될 때 (모든 걸 다 시도했다)

create-react-app으로 프로젝트를 생성 후 yarn start를 입력하니 갑자기 에러가 발생했다. There might be a problem with the project dependency tree. It is likely not a bug in Create React App, but somet..

letsgojieun.tistory.com