3

Every time I try running npm start on a new project I keep on getting this error. Does anyone know or have any idea how to fix this??

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": "^26.6.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:

D:\node_modules\babel-jest (version: 24.9.0)

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:

  1. 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.

  2. Check if D:\node_modules\babel-jest is outside your project directory. For example, you might have accidentally installed something in your home folder.

  3. 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! react-portfolio@0.1.0 start: react-scripts start npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the react-portfolio@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!
C:\Users\smaso\AppData\Roaming\npm-cache_logs\2021-01-26T22_50_48_484Z-debug.log

kca
  • 4,856
  • 1
  • 20
  • 41
Shawn Mason
  • 75
  • 1
  • 1
  • 7
  • Did you try the suggested fix ? Do you have `babel-jest v26.6` or higher in your package.json ? – kca Jan 27 '21 at 19:08
  • Does this answer your question? [NPM start returns error, "There might be a problem with the project dependency tree"](https://stackoverflow.com/questions/56528222/npm-start-returns-error-there-might-be-a-problem-with-the-project-dependency-t) – Henke Mar 12 '22 at 16:41

11 Answers11

12

I also face this problem. Simple solution of this problem is: 1)create .env file. 2) add SKIP_PREFLIGHT_CHECK=true in the file. 3) npm start

vikky singh
  • 356
  • 3
  • 6
7

If this fails to work, create a .env file in the root directory of your project and add the following line

SKIP_PREFLIGHT_CHECK=true
Slava Rozhnev
  • 9,510
  • 6
  • 23
  • 39
S.Kihara
  • 191
  • 2
  • 2
2

just go to your project's root directory and delete node_module folder and npm start your project.

sonali
  • 762
  • 10
  • 23
0

Delete and redownload node modules and run application again

0

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:

  1. 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.

  2. Check if ./babel-jest is outside your project directory. For example, you might have accidentally installed something in your home folder.

  3. 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.

S.Kihara
  • 191
  • 2
  • 2
0

Seems like you created the react project using create-react-app and installed jest using the following command.

yarn add --dev jest babel-jest @babel/preset-env @babel/preset-react react-test-renderer

But in the documentation it says just to run the following command if you are using create-react-app

yarn add --dev react-test-renderer

[See the documentation][1]https://jestjs.io/docs/tutorial-react

This worked for me.

0

I used the following command to uninstall jest npm uninstall jest in the root project folder (not the client) and then used the react scripts start command npm start and it worked

0

removing jest.config.js and uninstall ts-jest solved my problem

Acid Coder
  • 2,047
  • 15
  • 21
0

I'm assuming that you have a version conflict with the global version that you've installed on your machine.

deleting the problematic folders from the global path will solve the problem.

the global path in Mac is usually /Users/{user}/node_modules/

see this https://stackoverflow.com/a/76271193/11263188

relbns
  • 106
  • 1
  • 4
0

Run this command: npm audit fix --force. It will fix vulnerabilities in your project's dependencies by updating them to the latest available versions.

Note that using the "--force" option can potentially introduce compatibility issues or conflicts with your project's code or other dependencies, so test your project thoroughly after running it.

0

Please update your "react-scripts" in your package.json, use a newer version e.g.

"react-scripts": "5.0.1".

Delete node_modules and delete package-lock.json and install again with npm i. Then run again.

Explain: if you run "npm ls babel-jest", you can see a dependency to "npm ls jest-circus" and these versions cause the error. Updating the "react-scripts" will use updated "babel-jest"/"jest-circus".

No need to set SKIP_PREFLIGHT_CHECK=true, which also caused new errors in my case.

This solution for me.