最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - Webpack and webpack-dev-server installation error - Stack Overflow

matteradmin9PV0评论

I'm trying to install a Webpack and Babel to use React without CRA.

During installation webpack-dev-server, I've facing with some dependencies problems

PS C:\Users\Lebedev\Desktop\projects\frontend-graduation-project> npm install --save-dev webpack-dev-server
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! Found: [email protected]
npm ERR! node_modules/webpack
npm ERR!   peer webpack@">=2" from [email protected]
npm ERR!   node_modules/babel-loader
npm ERR!     dev babel-loader@"^8.2.1" from the root project
npm ERR!   peer webpack@"^4.27.0 || ^5.0.0" from [email protected]
npm ERR!   node_modules/css-loader
npm ERR!     dev css-loader@"^5.0.1" from the root project
npm ERR!   6 more (html-webpack-plugin, style-loader, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer webpack@"^4.0.0" from [email protected]
npm ERR! node_modules/webpack-dev-server/node_modules/webpack-dev-middleware
npm ERR!   webpack-dev-middleware@"^3.7.2" from [email protected]
npm ERR!   node_modules/webpack-dev-server
npm ERR!     dev webpack-dev-server@"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this mand with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\Lebedev\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A plete log of this run can be found in:
npm ERR!     C:\Users\Lebedev\AppData\Local\npm-cache\_logs\2020-11-15T12_42_34_324Z-debug.log
PS C:\Users\Lebedev\Desktop\projects\frontend-graduation-project>

My package.json file:

"dependencies": {
    "react": "^17.0.1",
    "react-dom": "^17.0.1"
  },
  "devDependencies": {
    "@babel/core": "^7.12.3",
    "@babel/preset-env": "^7.12.1",
    "@babel/preset-react": "^7.12.5",
    "babel-loader": "^8.2.1",
    "css-loader": "^5.0.1",
    "html-webpack-plugin": "^4.5.0",
    "style-loader": "^2.0.0",
    "webpack": "^5.4.0",
    "webpack-cli": "^4.2.0"
  }

What I already did and it still not help:

  1. Tried remove node_modules folder
  2. Tried remove package-lock.json file
  3. Reinstall npm dependencies by running this mand: npm install

How to solve this problems?

Thanks for any advice

I'm trying to install a Webpack and Babel to use React without CRA.

During installation webpack-dev-server, I've facing with some dependencies problems

PS C:\Users\Lebedev\Desktop\projects\frontend-graduation-project> npm install --save-dev webpack-dev-server
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! Found: [email protected]
npm ERR! node_modules/webpack
npm ERR!   peer webpack@">=2" from [email protected]
npm ERR!   node_modules/babel-loader
npm ERR!     dev babel-loader@"^8.2.1" from the root project
npm ERR!   peer webpack@"^4.27.0 || ^5.0.0" from [email protected]
npm ERR!   node_modules/css-loader
npm ERR!     dev css-loader@"^5.0.1" from the root project
npm ERR!   6 more (html-webpack-plugin, style-loader, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer webpack@"^4.0.0" from [email protected]
npm ERR! node_modules/webpack-dev-server/node_modules/webpack-dev-middleware
npm ERR!   webpack-dev-middleware@"^3.7.2" from [email protected]
npm ERR!   node_modules/webpack-dev-server
npm ERR!     dev webpack-dev-server@"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this mand with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\Lebedev\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A plete log of this run can be found in:
npm ERR!     C:\Users\Lebedev\AppData\Local\npm-cache\_logs\2020-11-15T12_42_34_324Z-debug.log
PS C:\Users\Lebedev\Desktop\projects\frontend-graduation-project>

My package.json file:

"dependencies": {
    "react": "^17.0.1",
    "react-dom": "^17.0.1"
  },
  "devDependencies": {
    "@babel/core": "^7.12.3",
    "@babel/preset-env": "^7.12.1",
    "@babel/preset-react": "^7.12.5",
    "babel-loader": "^8.2.1",
    "css-loader": "^5.0.1",
    "html-webpack-plugin": "^4.5.0",
    "style-loader": "^2.0.0",
    "webpack": "^5.4.0",
    "webpack-cli": "^4.2.0"
  }

What I already did and it still not help:

  1. Tried remove node_modules folder
  2. Tried remove package-lock.json file
  3. Reinstall npm dependencies by running this mand: npm install

How to solve this problems?

Thanks for any advice

Share Improve this question asked Nov 15, 2020 at 12:50 Boris LebedevBoris Lebedev 1433 silver badges10 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

I found the answer on a Github Issue page: https://github./npm/cli/issues/2119

My npm version has been 7.0.8. As a mvyunko mention in issue, I just type the following:

npm install npm@latest -g
npm install webpack-dev-server --save-dev

After all mands, my npm version has been changed to 6.14.8, and installation error has gone.

Post a comment

comment list (0)

  1. No comments so far