Today Sangmin Learned
728x90

여느때와 마찬가지로 새로운 React 프로젝트를 설치하고, yarn start를 통해 시작하려던 와중에 생전 처음 보는 에러가 발생했다.

There might be a problem with the project dependency tree.

It is likely not a bug in Create React App, but something you need to fix locally.

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

  "webpack": "4.42.0"

Don't try to install it manually: your package manager does it automatically.

However, a different version of babel-loader was detected higher up in the tree:

  /Users/sangminpark/Desktop/React/node_modules/webpack (version: 4.43.0) 

Manually installing incompatible versions is known to cause hard-to-debug issues.

If you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.

That will permanently disable this message but you might encounter other issues.

To fix the dependency tree, try following the steps below in the exact order:

  1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.

  2. Delete node_modules in your project folder.

  3. Remove "webpack" from dependencies and/or devDependencies in the package.json file in your project folder.

  4. Run npm install or yarn, depending on the package manager you use.

In most cases, this should be enough to fix the problem.

If this has not helped, there are a few other things you can try:

  5. If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.

     This may help because npm has known issues with package hoisting which may get resolved in future versions.

  6. Check if  /Users/sangminpark/Desktop/React/node_modules/webpack is outside your project directory.

     For example, you might have accidentally installed something in your home folder.

  7. Try running npm ls webpack in your project folder.

     This will tell you which other package (apart from the expected react-scripts) installed webpack.

If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.

내용을 읽어보니 설치된 webpack의 버전이 React 프로젝트에서 요구하는 webpack 버전보다 높기 때문에 발생한 오류같았다. 그래서 해당 절차를 따라가봤으나 예상대로 해결이 되지 않았고, 시간을 좀 썼는데.. 해결했다.

상위 폴더에 node_modules 폴더가 gitignore 처리도 안된 상태로 있길래 이게 뭐지? 하고 지웠더니 해결되었다. 오류 메시지에 나와있는 것처럼 .env에 들어가 SKIP_PREFLIGHT_CHECK=true 처리를 할 수도 있었겠으나, 뭔가 석연찮고 찜찜한 느낌이었다. 오류를 스킵하는거라 추후에 다른 에러가 발생할 여지가 있겠다고 생각했다. 그래서 그렇게 하진 않았다. 어쨌든 해결

profile

Today Sangmin Learned

@steadily-worked

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!