Issue with babel-jest dependency when running npm start in a React app Issue with babel-jest dependency when running npm start in a React app reactjs reactjs

Issue with babel-jest dependency when running npm start in a React app


I just had the same problem. For some reason the package ended up in a node_modules directory in my home directory. It also gave me the exact same error for the jest package.

I'm not sure of the correct way to fix this as npm uninstall -g babel-jest and yarn global remove babel-jest do not do anything.

I fixed it by just blowing away the folders that cause the problem:bashrm -rf ~/node_modules/babel-jest ~/node_modules/jest

It would be great to know how those packages ended up there, and the proper way of getting rid of them, but for now just deleting the folders is enough to get CRA dev server running without skipping the preflight check.


This problem can occur if there is node_modules in a parent directory of the folder where you run the application. I solved the problem by deleting the node_modules directory.


The problem seems to have reappeared in create-react-app 3.0.0.

The react-scripts package provided by Create React App requires a dependency:  "babel-jest": "24.7.1"

As abisuq pointed out in https://github.com/facebook/create-react-app/issues/6756#issuecomment-489562571 adding a version resolutions into package.json temporarily fixes the problem.

"resolutions": {  "babel-jest": "24.7.1"},

Update: It has been fixed in create-react-app 3.0.1. If upgrading is an option you can run

npm install --save --save-exact react-scripts@3.0.1

or

yarn add --exact react-scripts@3.0.1