본문 바로가기

개발개발

babel v7에서 babel-jest 적용기

babel v7에서 babel-jest 적용기

babel-jest 공식 페이지에 따르면 babel7에서 babel-jest를 사용하려면 다음 명령어로 babel-jest, babel-core@^7.0.0-bridge.0, @babel/core 를 설치해야 한다.

npm install -D babel-jest babel-core@^7.0.0-bridge.0 @babel/core regenerator-runtime

그런데 다음과 같은 에러가 나더라

Requires Babel "^7.0.0-0", but was loaded with "6.26.3". If you are sure you have a compatible version of @babel/core, it is likely that something in your build process is loading the wrong version. Inspect the stack trace of this error to look for the first entry that doesn't mention "@babel/core" or "babel-core" to see what is calling Babel. 
~~블라블라~~

이거저거 검색해서 별짓을 다해봤는데, 해결이 안됐음. 그러다가 matermost wepapp 소스를 봤는데 이놈도 바벨 v7인데 잘 동작하더라. 그래서 package.json 을 살펴보니... jest가 로컬에 설치되어 있었다. 난 jest를 글로벌에 설치했었는데....

그래서 로컬에도 jest를 설치해주니 잘 동작한다! 당황스럽다.... npm ls 명령어로 전역으로 설치된 jest를 보니 하위에 babel-core@6.26.3 이 보인다. 아무래도 전역에 설치된 jest가 문제가 되는것 같다. 로컬 설치 혹은 노드 재설치가 답이겠지...