Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NPM start returns error, "There might be a problem with the project dependency tree"

I'm new to coding and having issues with why I can no longer get React set up correctly. I struggled last week and then finally managed it. But now I have had the same issue again and nothing is working.

I have a project which I started with npx create-react-app and then when I cd into the project I guess this issue:

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:

"webpack": "4.29.6"

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

/Users/aliceparker/node_modules/webpack (version: 4.33.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 "webpack" 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 /Users/aliceparker/node_modules/webpack is outside your project directory. For example, you might have accidentally installed something in your home folder.

  3. Try running npm ls webpack in your project folder. This will tell you which other package (apart from the expected react-scripts) installed webpack.

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!

I've followed the steps above. Still get the issue. I've also uninstalled webpack globally and re-installed it.

Here is what my package.json file looks like:

`{   "name": "ravenous-app",   "version": "0.1.0",   "private": true,   "dependencies": {     "react": "^16.8.6",     "react-dom": "^16.8.6",     "react-scripts": "3.0.1"   },   "scripts": {     "start": "react-scripts start",     "build": "react-scripts build",     "test": "react-scripts test",     "eject": "react-scripts eject"   },   "eslintConfig": {     "extends": "react-app"   },   "browserslist": {     "production": [       ">0.2%",       "not dead",       "not op_mini all"     ],     "development": [       "last 1 chrome version",       "last 1 firefox version",       "last 1 safari version"     ]   } }` 

Can anyone kindly guide me through ways to solve this? (Ps. I tried just creating a new project, but get the same issue...)

like image 824
Alice Avatar asked Jun 10 '19 14:06

Alice


People also ask

How do you fix 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?

To Solve 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 Error You Just need to define SKIP_PREFLIGHT_CHECK=true in Your ENV file So That First of all Just Make . env File at root of your react projects Folder.

What does Skip_preflight_check true do?

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.


2 Answers

In my case, I solved my problem in this way

  1. create a .env at the root of the folder react folder
  2. type SKIP_PREFLIGHT_CHECK=true inside of .env file
  3. now run in cmd npm start .
like image 72
Krishna Jangid Avatar answered Sep 29 '22 09:09

Krishna Jangid


In the terminal, run:

cd ~

Then:

ls

You should see a list of files. If node_modules is included in that list (as it appears it should be), you want to delete that folder. You can do so in the terminal like so:

rm -rf node_modules

But keep in mind: this will not send the folder to the trash. It will irrevocably delete it. rm -rf is a powerful command. If that makes you nervous, type open . instead. That will open your "home" (~) directory in Finder, and you can delete node_modules in the familiar, right-click, send-to-trash way there.

Hope that helps!

like image 35
davidfloyd91 Avatar answered Sep 29 '22 10:09

davidfloyd91