본문 바로가기
ERROR

[React] The react-scripts package provided by Create React App requires a dependency: (npm run start 안될 때)

by Ellie.P 2023. 12. 22.
반응형
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:

  "babel-jest": "23.6.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/.../node_modules/babel-jest (version: 25.5.1) 

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 "babel-jest" 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/.../node_modules/babel-jest is outside your project directory.
     For example, you might have accidentally installed something in your home folder.

  7. Try running npm ls babel-jest in your project folder.
     This will tell you which other package (apart from the expected react-scripts) installed babel-jest.

If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That would permanently disable this preflight check in case you want to proceed anyway.

P.S. We know this message is long but please read the steps above :-) we hope you find them helpful!

npm run start 만 하면 이 에러 메세지가 떴다.


원인

React App 에서 요구하는 버전과 다르기 때문이다.

해결 방법

1. 오류가 발생하는 모듈 폴더를 찾는다.

🚨 babel-jest를 검색하면 여러 버전의 babel-jest 폴더들이 있을 것이다. 그 중 오류가 나는 version이 있는 폴더를 찾아야한다. 🚨

2. 오류가 나는 version이 있는 폴더를 삭제한다.

3. npm run start 를 해본다.


해결 완료!!

 

이 에러를

해결하는데 생각보다 많은 시간을 사용하였다.

요구하는 버전으로도 설치해보고  아래와 같은 방법으로도 해 보았으나 나는 해결되지 않았다.

반응형