question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

react-scripts is using webpack version "4.44.2" instead of "^5.61.0"

See original GitHub issue

I am using react-scripts version ^4.0.3 in my project. I also use react-app-rewired, stylelint and stylelint-webpack-plugin (latest versions).

When I am trying to run npm start, I am getting the following error from react-scripts installed by Create React App:

There might be a problem with the project dependency tree.
project | It is likely not a bug in Create React App, but something you need to fix locally.
project | 
project | The react-scripts package provided by Create React App requires a dependency:
project | 
project |   "webpack": "4.44.2"
project | 
project | Don't try to install it manually: your package manager does it automatically.
project | However, a different version of webpack was detected higher up in the tree:
project | 
project |   /var/node/app/node_modules/webpack (version: 5.62.1) 
project | 
project | Manually installing incompatible versions is known to cause hard-to-debug issues.
project | 
project | If you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
project | That will permanently disable this message but you might encounter other issues.
project | 
project | To fix the dependency tree, try following the steps below in the exact order:
project | 
project |   1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
project |   2. Delete node_modules in your project folder.
project |   3. Remove "webpack" from dependencies and/or devDependencies in the package.json file in your project folder.
project |   4. Run npm install or yarn, depending on the package manager you use.
project | 
project | In most cases, this should be enough to fix the problem.
project | If this has not helped, there are a few other things you can try:
project | 
project |   5. If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
project |      This may help because npm has known issues with package hoisting which may get resolved in future versions.
project | 
project |   6. Check if /var/node/app/node_modules/webpack is outside your project directory.
project |      For example, you might have accidentally installed something in your home folder.
project | 
project |   7. Try running npm ls webpack in your project folder.
project |      This will tell you which other package (apart from the expected react-scripts) installed webpack.
project | 
project | If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
project | That would permanently disable this preflight check in case you want to proceed anyway.
project | 
project | P.S. We know this message is long but please read the steps above :-) We hope you find them helpful!
project | 

It seems that the plugin of stylelint-webpack-plugin requires to have webpack version 5.62.1. But it founds version 4.44.2 instead.

I checked the version of webpack in package.json file of react-scripts under node_modules and found this:

"webpack": "4.44.2",

It seems that react-scripts is installing older version of webpack.

When I looked into the official package.json file of react-scirpts I found that it using webpack version 5.61.0 as expected.

https://github.com/facebook/create-react-app/blob/main/packages/react-scripts/package.json

How come there are differences between what I have locally and what we have here in the official repo?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
sunith-kumarcommented, May 28, 2022

This issue is till there

0reactions
stale[bot]commented, Jan 9, 2022

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

react-scripts required old version of webpack - Stack Overflow
I see that in node_modules version is 4.43 and after I use npm install webpack in the file package-loc. json it shows 4.43,...
Read more >
How to Upgrade to React 17 and Webpack 5 Step by Step
How to Upgrade to React 17 and Webpack 5 Step by Step · Make sure your Node version is above 10.13.0. > node...
Read more >
Webpack - npm
Renders Pug files to HTML, extracts JS and CSS from sources specified directly in Pug. Loaders. Webpack enables the use of loaders to...
Read more >
HOW DO I FIX THIS ERROR : r/reactjs - Reddit
The react-scripts package provided by Create React App requires a dependency: "webpack": "4.44.2". Don't try to install it manually: your ...
Read more >
Using Create-React-App + Craco + Typescript to build apps ...
With create-react-app it is easy to setup a project for Web development because details about configuring things like webpack are handled ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found