3

i have installed webpack with below command

yarn add webpack --dev

and after i ran yarn start command inside my react app folder

D:\Workspace\fuel-man-ui\fuel-man-ui>yarn start

Getting below error.

yarn run v1.19.0 $ react-scripts start

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:

D:\Workspace\fuel-man-ui\fuel-man-ui\node_modules\webpack (version: 4.41.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 D:\Workspace\fuel-man-ui\fuel-man-ui\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!

error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

i have deleted node_modules from my project and devdependencies, also i have removed global node_modules and cache. still getting same error.

I ran npm ls webpack and got below tree

[email protected] D:\Workspace\fuel-man-ui\fuel-man-ui
+-- [email protected]
| `-- [email protected]
|   `-- [email protected]  extraneous
`-- [email protected]

npm ERR! extraneous: [email protected] D:\Workspace\fuel-man-ui\fuel-man-ui\node_modules\react-scripts\node_modules\webpack\node_modules\webpack
9
  • From the logs you're using create-react-app, which comes bundled with webpack.. why do you want to add..webpack? It literally gives you the reason in the logs if you read it: 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: Commented Oct 4, 2019 at 9:21
  • no webpack was not there, my css modules are not working without webpack Commented Oct 4, 2019 at 9:25
  • 1
    webpack is auto installed since you used create-react-app.. Commented Oct 4, 2019 at 9:31
  • do i need to add webpack in devdependency, to make css modules work? Commented Oct 4, 2019 at 9:38
  • create-react-app.dev/docs/adding-a-css-modules-stylesheet Commented Oct 4, 2019 at 10:01

4 Answers 4

3

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:

In project root delete node_modules and yarn.lock. In package.json remove webpack from the dependencies and run yarn again.

If you want to modify webpack.config for this project you can run yarn eject from here on you are responsible for the webpack.config so it will be harder to update react scripts.

If you don't want to be responsible for the webpack.config you could try to use react-app-rewired an article on this is here

Sign up to request clarification or add additional context in comments.

7 Comments

you mean the webpack is default installed? no need to install webpack explicitly.but my css modules are not working..with default webpack installed
@pappu_kutty If you only want to add a module you can use rewire to add the module to the rewire config.
my css modules are not working.. i was told to add webpack dependency to make it work... probably i should work with default dependency suggested by Dragos
@pappu_kutty That would be the easiest solution. But if you really need to modify webpack.config you can opt for react-app-rewired before ejecting the config.
i am just going with default webpack config... i am following this post stackoverflow.com/questions/50234890/…
|
1

You should create .env file in the root (not inside src folder) and add SKIP_PREFLIGHT_CHECK=true Then you can use yarn start or npm start. It works!

Comments

0

Yesterday I had the same issue. In my case it turned out, that I had two installations of node (one using brew, one using downloaded dmg file). It helped when I removed the one installed via brew.

Comments

0

The file .env with added SKIP_PREFLIGHT_CHECK=true

1 Comment

Hi, welcome to stack overflow. For a useful answer explain why this is an answer to the question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.