6.08.2020

create-react-app의 babel-jest와 Node.js 서버 쪽 jest의 충돌 에러

create-react-app의 babel-jest와 Node.js 서버 쪽 jest의 충돌 에러

어제 jest로 서버 쪽에서 API 테스트를 돌렸다. 그리고 오늘 로컬로 client를 돌리는데 npm start를 쳤더니 위와 같은 에러가 나왔다.


에러가 설명해주는대로 삭제할 것들 삭제하고 다시 npm install 해보았지만 여전히 작동하지 않았다. 뭐가 문제인지 고민하던 중 6번의 For example, 이라는 예시가 눈에 들어왔다. 테스트를 만들고 나서 문제가 생긴 것 같은데, 테스트를 위해서 서버 쪽 package.json에 jest와 supertest를 설치했던 것이 생각났다. 혹시나 해서 서버 쪽에 설치한 jest와 supertest를 uninstall하고 나니 client에서 npm start가 제대로 돌아갔다.


실제로 workflow를 짤 때, test하는 과정에서는 jest와 supertest를 설치하고 API가 잘 작동한다는 것을 확인한 후에는 uninstall 해주고 client를 돌려야겠다는 생각이 들었다.



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": "^24.9.0"

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

  /home/swimmingkiim/Documents/self_study/Portfolio/GoogleCloud/WatchFolio/node_modules/babel-jest (version: 26.0.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 /프로젝트 폴더 경로(서버쪽)/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 ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! watch_folio@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the watch_folio@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/swimmingkiim/.npm/_logs/2020-06-08T03_50_09_353Z-debug.log


Share:

0 comments:

댓글 쓰기