andrrrrrre
andrrrrrre

Reputation: 135

react-scripts required old version of webpack

I installed webpack into my react project, but the same error occurred every time when I use npm start:

The react-scripts package provided by Create React App requires a dependency:

"webpack": "4.42.0"

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:

C:\react\minimoj\node_modules\webpack (version: 4.43.0)

I tried to remove package-loc.json file + all node_modules + remove webpack name from package.json and reinstall it with npm install. Also I tried same with yarn, but it didn't help. 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, but at the moment when I use npm start it changed to 4.42 and error occur. In addition I also reinstall node.js but it didn't help.

Upvotes: 11

Views: 9119

Answers (3)

Carlos Pimentel
Carlos Pimentel

Reputation: 489

Since webpack is mostly focused on common js according to some websites, I just tried rollup for my react project and it proved to be much more effective as it supports es+. I would highly recommend it. I took a couple minutes to have everything setup and ready. Also, as a good practice it is better to use yarn as npm has had a lot of known issues for node app management.

Upvotes: 0

Hemmels
Hemmels

Reputation: 892

I had similar with a newer webpack version being installed than what react_scripts required. To fix I deleted webpack and webpack-dev-server from my project's node_modules, went to a console outside of the project dir and ran

npm uninstall webpack
npm uninstall webpack-dev-server

Then ran

npm install
npm run build

And all was well, as my package.json was correct without change.

Upvotes: 2

Edvin Saletovic
Edvin Saletovic

Reputation: 31

create .env file and add SKIP_PREFLIGHT_CHECK=true

Upvotes: 3

Related Questions