score:39

Accepted answer

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: bash rm -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.

score:-4

i had the similar problem and wasted my 2-3 days The easiest way to solve this problem is :

1.go outside of src, and create .env file. 2.Inside .env file, just write this single line and save it: SKIP_PREFLIGHT_CHECK=true 3.then npm start

Hope this helps, Happy coding!!!

score:0

I had the exact same issue. What I tried was to create the react app outside the directory that had the node_modules folder. After that, started the app with yarn start and didn't have the error anymore.

score:0

I had the same problem, and I fixed this issue. For some reason because node_modules on my local. I removed babel-jest & jest. After that, npm start. I'm not sure this solved incorrect but this correct for me.

score:0

I solved this issue by deleting the node_modules folder and package-lock.json file I accidentally had installed in the root of my user.

For me in Mac the path was:

Macintosh HD -> Users -> "My-user-name"

I discover that might be the problem by running npm ls babel-jest on terminal. That showed me that there was another babel-jest up in the tree.

After deleting these two I did npm install in my app where I previously had deleted the node_modules folder and package-lock.json.

Now it's running ok !

score:0

I fixed this by deleting node_module folder in the project directory

score:0

try this command and see which packages create conflicts in versions.

npm ls babel-jest

replace the conflicted packages with updated one of that package.

score:0

I tried all of written solutions above. But none of them worked. I solved problem by deleting "C:\node_modules" folder. Then delete project node_modules and package-lock.json. Finally, npm install and start again. And it worked.

score:0

My react-scripts version is 4.0.3. The problem suddenly happened after installing a private remote package, which installed multiple babel packages in my project root's node_modules. I solved this by installing the problematic packages on the project root's level explicitly, so that they match the versions reported in the preflight check.

Following addings fixed it in my case. Your needed packages and versions may differ, you have to check the preflight report.

yarn add babel-jest@^26.6.0
yarn add babel-loader@8.1.0

For me its still a workaround, but i prefer this way instead of removing something in node_modules manually as suggested in https://stackoverflow.com/a/53093421/4840661.

score:0

This is the approach without deleting node_modules:

  • I recieved error like:

The react-scripts package provided by Create React App requires a dependency: "jest": "26.6.0" Don't try to install it manually: your package manager does it automatically. However, a different version of jest was detected higher up in the tree:

  • First check the versions using:

    npm ls babel-jest

    In my case output was like this:

jest@27.0.3
└─┬ @jest/core@27.0.3
└─┬ jest-config@27.0.3
└── babel-jest@27.0.2

  • After that uninstall babel-jest by
    npm uninstall babel-jest
    (When you see the single version of babel-jest,otherwise go as versions as follows)
    npm uninstall babel-jest@27.0.2

  • Then install required dependencies using
    npm i babel-jest@version jest@version
    (Where version is the one come in 1st point)

This works for me like a charm. Hope this solves you too.

score:0

Got this error in the netlify ci, here's the fix that worked for me: this method works for any lib i got a error for eslint instead of babel-jest.

  1. force the error to be shown by npm i -s @babel-jest/VERSION --force

    replace VERSION with whatever version shows in the error(23.6.0 in this case), the correct error message will be shown locally

  2. use https://www.npmjs.com/package/npm-check-updates to upgrade your package.json flie with the correct versions

    run ncu -u in dir of package.json after installing the npm package globally

  3. finally do a npm ci

    this will delete the package-lock and node_modules and install the new versions based on the second step

score:0

this work for me. clear caches in npm or yarn remove node_modules and lock files

  • create .env file
  • add " SKIP_PREFLIGHT_CHECK=true " to an .env file in your project.

score:0

my issue was that I have both frontend and backend that I am running concurrently. I installed jest to my root project (for backend) and I guess there is collision with pre-installed react jest. I just uninstalled jest from backend and voila I am happy now. I don't have anything related with babel.

score:1

I was having this issue as well. When I tried to run the client using npm start, the error would occur, telling me that it required babel-jest: ^24.9.0.

I noticed that in my client, babel-jest was version ^24.9.0, but in my server, I had "jest": "^26.6.3".

All I had to do was change "jest": "^26.6.3" to "jest": "^24.9.0" in the server side source code, delete my package-lock.json as well as node_modules in server, npm install again, and good to go!

score:3

I fixed the issue by removing the node_modules folder and package-lock.json file from a folder that was higher than the root of the project. I had installed node_modules accidentally in a higher folder.

I had:

  • desktop/code/node_modules (remove this to fix)
  • desktop/code/package-lock.json (remove this to fix)
  • desktop/code/project/node_modules
  • desktop/code/project/package-lock.json

score:4

  1. run: npm ls babel-jest

got : babelk-jest@24.7.1 & babel-jest@24.8.0 installed

this means install tow babel-jest with diff version

  1. run:npm uninstall babel-jest@24.8.0 fix my issue

score:5

I had this issue and finally solved it easily. As probably you know, when we use create-react-app, Jest is configured by default and you don't need to install Jest (when we use Webpack, we can install Jest). So, if you use Create-react-app and install Jest by mistake:

  1. Firstly uninstall it (remember that if you use: (npm install --save-dev jest), you can remove jest directly from Package.json or use: (npm uninstall --save-dev jest)
  2. Delete package-lock.json (not package.json)
  3. Delete the node_modules
  4. npm install

Now you don't receive an error and you can easily use: (npm start) or (npm test)

Also, It is worth mentioning that I installed the following tools to write my test in React component: (npm install --save-dev enzyme enzyme-adapter-react-16 jest-enzyme) and wrote my test by using jest and enzyme. Then I easily use: (npm test)

Good Luck!

score:5

Ok I finally found a solution after trying everything. Here is what finally worked:

  • First of all, read the error message in the cmd from the beginning. They'll tell you what module is causing the problem. You probably have an older version installed on your computer. Example: babel-jest version 2.4.4
  • Go to your Node.js folder c:/Users/(your user)/node_modules and find that module and simply delete it.
  • Go back to the cmd and run npm start. You might get the same error. But it'll be for a different module. Just delete it the same way and repeat until it runs.

score:19

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

score:21

I too faced a similar problem and was able to resolve the issue following below steps.

  1. Create a .env file in your project root directory and add the following statement

SKIP_PREFLIGHT_CHECK=true

  1. Save the file

  2. Remove node_modules, yarn.lock, package.lock

  3. Then reinstall node_modules with

npm install

This should work

score:34

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.


Related Query

More Query from same tag