46

I'm new to coding and having issues with why I can no longer get React set up correctly. I struggled with this 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 get 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...)

Henke
  • 4,445
  • 3
  • 31
  • 44
Alice
  • 612
  • 1
  • 5
  • 13
  • Just note, since neither deletion of node_modules or silencing of the error is a great solution for production, this warning likely comes from a conflict between two different packages at different stages, requiring different webpacks. Eg react scripts wants one webpack and storybook wants another. – Kzqai Jun 16 '21 at 00:37
  • Go and check this post... It help me https://stackoverflow.com/a/60947470/11510800 – kouameYao Feb 21 '22 at 22:58

25 Answers25

61

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 .
Neel Sandell
  • 429
  • 5
  • 12
Krishna Jangid
  • 4,961
  • 5
  • 27
  • 33
35

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!

davidfloyd91
  • 519
  • 3
  • 7
  • Are you getting the same error messages as in the original post? Or something different? Edit: Did you `cd` back into the project directory before running `npm start`? – davidfloyd91 Jun 10 '19 at 15:31
  • npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! react-app@0.1.0 start: `react-scripts start` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the react-app@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! /Users/alice/.npm/_logs/2019-06-10T14_56_11_380Z-debug.log Alices-MBP-7:react-app alice$ – Alice Jun 10 '19 at 16:40
  • Hm, maybe this thread will help: https://stackoverflow.com/questions/42308879/npm-err-code-elifecycle – davidfloyd91 Jun 10 '19 at 16:50
  • Unfortunately not :( I'm just back at the same issue when I complete the steps, re-install npm and then npm start. – Alice Jun 10 '19 at 17:02
  • Are you still seeing this message? "However, a different version of webpack was detected higher up in the tree: /Users/aliceparker/node_modules/webpack" – davidfloyd91 Jun 10 '19 at 17:05
  • Yes, it is still there. Shall I delete webpack from the global user folder? – Alice Jun 10 '19 at 17:12
  • Yes you should delete `node_modules` and `package-lock.json` from `/Users/aliceparker`. https://stackoverflow.com/questions/53497035/why-there-is-a-node-modules-folder-under-my-home-folder – davidfloyd91 Jun 10 '19 at 17:50
  • Yes!! Thank you! Wow I have been going round in circles all weekend on this! What I did: deleted the node modules and package-lock from global (perhaps i hadn't deleted both previously) and then npm cache verify. – Alice Jun 10 '19 at 18:02
  • 2
    Just to specify, I had done all the steps to solve the problem and no matter what it didn't work. I discovered that I had a node_modules folder in my user's folder. I deleted this one, but not the one in my project and then could use "npm start" whitout any issue. – Seb May 18 '20 at 10:06
  • I have ran into the same issue and after some research here are some thoughts: react js, does not require webpack and this is the dependency which is causing the errors, as it is not meeting the peer dependencies. So the simplest thing I have done is: removed webpack and babel dependencies and my app ran smoothly. By the way I am using react version 17.0.2. For further reading you may check the link https://javascript.plainenglish.io/why-you-should-not-use-webpack-f07f4fd7c116 – Carlos Pimentel Jul 06 '21 at 17:24
  • @Seb - Thank you!!! Was having the same issue and couldn't figure out the solution until I found your comment. – redliz5808 Apr 28 '22 at 13:54
  • why there are node_modules installed in my home dir? – Sanira Nimantha Jan 05 '23 at 11:41
15

Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.

Delete node_modules in your project folder.

Remove webpack from dependencies and/or devDependencies in the package.json file in your project folder.

Run npm install or yarn, depending on the package manager you use.

I tried all of the above and it was not working but once i added a .env file to my project structure and added SKIP_PREFLIGHT_CHECK=true into the file. i could bypass the problem:

problem solved

This what you put inside the .env file:

This what you put inside the .env file

xiawi
  • 1,772
  • 4
  • 19
  • 21
annon bytes
  • 161
  • 1
  • 6
7

you need to try first, make a file with the name .env and store the SKIP_PREFLIGHT_CHECK=true

root/.env and .env should contain SKIP_PREFLIGHT_CHECK=true

4
  1. create a .env file or edit exiting one.
  2. SKIP_PREFLIGHT_CHECK = true write this to .env file.
  3. restart dev server.

I solved the problem this way.

dipenparmar12
  • 3,042
  • 1
  • 29
  • 39
bek
  • 49
  • 1
  • 2
3

The issue is the webpack installed in your user directory. Remove it with npm or by hand and all should run fine: ref: https://github.com/facebook/create-react-app/issues/6120

Mosè Raguzzini
  • 15,399
  • 1
  • 31
  • 43
2

You can follow the instructions given in the error log.

  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.

  • Thanks. I have tried these steps already but just be clear, I wasn't sure on if I did step 3 correctly. How exactly do I do that? – Alice Jun 10 '19 at 14:39
  • open package.json, under dependencies or devDependencies remove reference to webpack. – coldbreathe Jun 10 '19 at 15:56
  • 3
    There is no reference to the webpack there.. "dependencies": { "react": "^16.8.6", "react-dom": "^16.8.6", "react-scripts": "3.0.1" }, – Alice Jun 10 '19 at 17:41
2
  • add "webpack": "4.44.2" to dependencies of package.json.
  • create .env and type SKIP_PREFLIGHT_CHECK=true That will be solved your problem.
2

In my case, I removed node_modules from my user's directory. It worked.

S6rra
  • 61
  • 2
1

The solution that worked for me

Add SKIP_PREFLIGHT_CHECK=true to a .env file in your project. I don't know if this may result in errors in the future.

dboy
  • 1,004
  • 2
  • 16
  • 24
Addo
  • 273
  • 3
  • 8
1

Remove the node_modules from your user directory i.e C:\Users\User

  • I've tried all the above methods but I completely forgot about removing my node modules from C:\Users\user folder. Thanks a lot @Emmanuel – xander cage Jun 03 '21 at 07:02
1

Add the line"webpack": "4.44.2" to the dependencies of your package.json file. Create the .env file, and type SKIP_PREFLIGHT_CHECK=true inside, which will solve your problem.

Orlyyn
  • 2,296
  • 2
  • 20
  • 32
1

I've been stuck on this for over an hour. I followed every step listed. I deleted node_modules from my project and ALL node modules folders found on my mac. Then I deleted packagelock and then ran npm install which gave me a fresh nm and packagelock.

Running npm start keeps giving me the same error. I know it's not my code because I can checkout another branch and I get the same error.

This all started when I installed react testing library and upgraded react-scripts from 2.1.1 to 4.. I upgraded due to an error after running a test that said something about react-scripts (I can't remember what it said exactly.)

I have since reset my package.json to the old working version with the old react-scripts version and without the testing libraries, followed all the above steps again, and still have the error.

I don't have webpack in dependencies or dev dependencies.

Here is my previously working package.json

{
    "name": "bidrlfront",
    "version": "1.0.0",
    "private": true,
    "homepage": "./",
    "dependencies": {
      "@date-io/moment": "^1.3.13",
      "@material-ui/core": "^4.12.3",
      "@material-ui/icons": "^4.11.2",
      "@material-ui/pickers": "^3.3.10",
      "camelize": "^1.0.0",
      "chart.js": "^2.7.3",
      "classnames": "^2.2.6",
      "cross-env": "^5.2.0",
      "css-loader": "^1.0.0",
      "dateformat": "^3.0.3",
      "flux": "^3.1.3",
      "lodash.find": "^4.6.0",
      "moment": "^2.29.1",
      "node-sass": "^4.14.1",
      "react": "^16.14.0",
      "react-bootstrap": "^1.6.1",
      "react-dom": "^16.6.3",
      "react-ga": "^2.5.6",
      "react-loading": "^2.0.3",
      "react-quill": "^1.3.3",
      "react-router": "^4.3.1",
      "react-router-dom": "^5.2.0",
      "react-scripts": "2.1.1",
      "shards-react": "^1.0.0",
      "shortid": "^2.2.14"
    },
    "scripts": {
      "start": "react-scripts start",
      "build:prod": "cross-env REACT_APP_BASENAME=/demo/shards-dashboard-lite-react REACT_APP_GAID=UA-115105611-1 npm run build",
      "build": "cross-env REACT_APP_BASENAME=/demo/shards-dashboard-lite-react react-scripts build",
      "test": "react-scripts test",
      "scss": "node-sass --watch -include-path src/css -o css",
      "eject": "react-scripts eject",
      "gitty": "node g.js"
    },
    "eslintConfig": {
      "extends": "react-app"
    },
    "browserslist": [
      ">0.2%",
      "not dead",
      "not ie <= 11",
      "not op_mini all"
    ],
    "devDependencies": {
      "sass-loader": "^7.1.0"
    },
    "repository": {
      "type": "git",
      "url": "git+ssh://git@bitbucket.org/rldev2/bidrl-app.git"
    },
    "keywords": [],
    "author": "Stephanie Raymos <sraymos@rlliquidators.com>",
    "license": "ISC"
  }

And here is my package.json when the errors started occuring

{
    "name": "bidrlfront",
    "version": "1.0.0",
    "private": true,
    "homepage": "./",
    "dependencies": {
        "@date-io/moment": "^1.3.13",
        "@material-ui/core": "^4.12.3",
        "@material-ui/icons": "^4.11.2",
        "@material-ui/pickers": "^3.3.10",
        "@testing-library/jest-dom": "^5.14.1",
        "@testing-library/react": "^12.0.0",
        "@testing-library/user-event": "^13.2.1",
        "camelize": "^1.0.0",
        "chart.js": "^2.7.3",
        "classnames": "^2.2.6",
        "cross-env": "^5.2.0",
        "css-loader": "^1.0.0",
        "dateformat": "^3.0.3",
        "flux": "^3.1.3",
        "lodash.find": "^4.6.0",
        "moment": "^2.29.1",
        "node-sass": "^4.14.1",
        "react": "^16.14.0",
        "react-bootstrap": "^1.6.1",
        "react-dom": "^16.6.3",
        "react-ga": "^2.5.6",
        "react-loading": "^2.0.3",
        "react-quill": "^1.3.3",
        "react-router": "^4.3.1",
        "react-router-dom": "^5.2.0",
        "react-scripts": "^2.1.1",
        "shards-react": "^1.0.0",
        "shortid": "^2.2.14"
    },
    "scripts": {
        "start": "react-scripts start",
        "build:prod": "cross-env REACT_APP_BASENAME=/demo/shards-dashboard-lite-react REACT_APP_GAID=UA-115105611-1 npm run build",
        "build": "cross-env REACT_APP_BASENAME=/demo/shards-dashboard-lite-react react-scripts build",
        "test": "react-scripts test",
        "scss": "node-sass --watch -include-path src/css -o css",
        "eject": "react-scripts eject",
        "gitty": "node g.js"
    },
    "eslintConfig": {
        "extends": "react-app"
    },
    "browserslist": [
        ">0.2%",
        "not dead",
        "not ie <= 11",
        "not op_mini all"
    ],
    "devDependencies": {
        "sass-loader": "^7.1.0"
    },
    "repository": {
        "type": "git",
        "url": "git+ssh://git@bitbucket.org/rldev2/bidrl-app.git"
    },
    "keywords": [],
    "author": "Stephanie Raymos <sraymos@rlliquidators.com>",
    "license": "ISC"
}

I had also globally installed testing library and fsevents prior to the error occuring but uninstalled those and trashed the folders on my mac.

I installed fsevents after receiving this error when I attempted to run my app after installing the testing libraries: Error: fsevents unavailable (this watcher can only be used on Darwin)

I was getting a blank screen. This solved that issue. I then got an error logging with my auth system. I was using rxjs. I had to install that. Got a react-scripts error and updated that to the latest version. That's when everything broke. When I run npm ls webpack I get this:

├─┬ css-loader@1.0.1
│ └─┬ webpack@4.46.0
│   └─┬ terser-webpack-plugin@1.4.5
│     └── webpack@4.46.0 deduped
├─┬ react-scripts@2.1.1
│ ├─┬ babel-loader@8.0.4
│ │ └── webpack@4.46.0 deduped
│ ├─┬ css-loader@1.0.0
│ │ └── webpack@4.19.1 deduped
│ ├─┬ eslint-loader@2.1.1
│ │ └── webpack@4.46.0 deduped
│ ├─┬ file-loader@2.0.0
│ │ └── webpack@4.46.0 deduped
│ ├─┬ fork-ts-checker-webpack-plugin-alt@0.4.14
│ │ └── webpack@4.46.0 deduped
│ ├─┬ html-webpack-plugin@4.0.0-alpha.2
│ │ └── webpack@4.46.0 deduped
│ ├─┬ mini-css-extract-plugin@0.4.3
│ │ └── webpack@4.46.0 deduped
│ ├─┬ optimize-css-assets-webpack-plugin@5.0.1
│ │ └── webpack@4.46.0 deduped
│ ├─┬ sass-loader@7.1.0
│ │ └── webpack@4.19.1 deduped
│ ├─┬ terser-webpack-plugin@1.1.0
│ │ └── webpack@4.46.0 deduped
│ ├─┬ url-loader@1.1.1
│ │ └── webpack@4.46.0 deduped
│ ├─┬ webpack-dev-server@3.1.9
│ │ ├─┬ webpack-dev-middleware@3.4.0
│ │ │ └── webpack@4.46.0 deduped
│ │ └── webpack@4.46.0 deduped
│ ├─┬ webpack-manifest-plugin@2.0.4
│ │ └── webpack@4.46.0 deduped
│ ├─┬ webpack@4.19.1
│ │ └─┬ uglifyjs-webpack-plugin@1.3.0
│ │   └── webpack@4.46.0 deduped
│ └─┬ workbox-webpack-plugin@3.6.3
│   └── webpack@4.46.0 deduped
└─┬ sass-loader@7.3.1
  └── webpack@4.46.0 deduped
Stephanieraymos
  • 186
  • 1
  • 8
1

The simple solution is just to install the webpack version shown in error.

npm install webpack@version show in error.

I hope this will help you. Thank you very much.

0

The problem is with your tree folder on your computer when you make all projects,try the app in folder not on exist one and i hope it will work

viso
  • 1
0

Do as it's saying on the error to make it work.
Create a .env file in your project directory and add SKIP_PREFLIGHT_CHECK=true, it will work.

סטנלי גרונן
  • 2,917
  • 23
  • 46
  • 68
  • 1
    This is not a solution, in most cases it will just hide the error but other problems arise later. – Mooncake Jun 26 '20 at 19:41
0

I have faced the same problem before and I solved it. The create-react-app already provided webpack(v4.29.6), which conflicts with webpack(v4.33.0) in /Users/aliceparker/node_modules.

So if you remove the second webpack(v4.33.0), it would run.

Jan Schultke
  • 17,446
  • 6
  • 47
  • 96
Daisy
  • 1
0

I created project using npx and I was getting same error with babel-eslint initially. I followed @davidflyod91 approach, it worked for me. Im not happy with deleting the whole node_module folder from ~ directory (in my MAC)(i mean to say the place where -g modules are installed). So, I put back the node_modules and deleted folders associate with below ones from node_modules in ~/node_modules directory and tried running the application (npm run start).

  • Webpack
  • babel
  • eslint
  • create-react-app

And then application started working.

0

create an .env file and put this line "SKIP_PREFLIGHT_CHECK=true"

example

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 13 '21 at 00:06
0

You can simply delete the node_module folder. it will work. Go to the root and then run the following command

sudo rm -rf /Users/yourname/node_modules
Junip Dewan
  • 759
  • 8
  • 8
0

I had the same error and none of the solutions helped me fully. Then I actually followed the instructions on the error and the issue was resolved

  1. Deleted package-lock.json
  2. Delete node_modules in the project folder.
  3. Make sure to run npm install. If you dont and go straight to npm start you will have a "react-scripts: command not found error"

Edit:Issue reoccured and was resolved by adding the .env file to the root of my project and added SKIP_PREFLIGHT_CHECK=true into the file.

Issue was fully resolved now.

  • 1
    Using SKIP_PREFLIGHT_CHECK is probably not a great idea because you're suppressing the issue and not resolving the problem. If the error persists, it's better to find the conflicting dependencies and resolving those. – ferdil Nov 30 '22 at 06:39
  • Using SKIP_PREFLIGHT_CHECK is probably not a great idea because you're suppressing the issue and not resolving the problem. If the error persists, it's better to find the conflicting dependencies and resolving those – ferdil Nov 30 '22 at 06:39
0
  • First try npm install, then npm start
  • If it doesn't work then run npm audit
  • Then try npm audit fix or npm audit fix --force, then npm install, then npm start
  • If it still doesn't work, delete node modules, package-lock.json and again try npm install, then npm start

Still getting error? Set SKIP_PREFLIGHT_CHECK=true inside of .env file

And try again.

Indranil
  • 2,229
  • 2
  • 27
  • 40
0

I had .env with SKIP_PREFLIGHT_CHECK=true in it.

Deleted node_modules, reinstalled and got same error, including suggestion to add .env I already had.

So, I deleted .env and added it again with the same SKIP_PREFLIGHT_CHECK=true in it.

The problem was solved.

Mary N
  • 75
  • 1
  • 2
  • 6
-1

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 /home/omage/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.

Answer To fix the dependency tree

to solve a dependency tree problem, you have to delete the node-modules file from your local computer and run npm start , to start the localhost

-1

I created .env file and i added SKIP_PREFLIGHT_CHECK=true in it.

Note: don't give any name to .env file, created filname must be .env

picture for more understanding