Error encountered during installation of Webpack and webpack-dev-server

I'm currently working on setting up Webpack and Babel for utilizing React without Create React App (CRA).

While trying to install webpack-dev-server, I encountered some dependency issues.

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: <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="86f1e3e4f6e7e5edc6b3a8b2a8b6">[email protected]</a>
npm ERR! node_modules/webpack
npm ERR!   peer webpack@">=2" from <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="afcdcecdcac382c3c0cecbcaddef97819d819e">[email protected]</a>
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 <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="791a0a0a541516181d1c0b394c57495748">[email protected]</a>
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 <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5c2b393e2c3d3f377138392a713135383830392b3d2e391c6f726b726e">[email protected]</a>
npm ERR! node_modules/webpack-dev-server/node_modules/webpack-dev-middleware
npm ERR!   webpack-dev-middleware@"^3.7.2" from <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f285979082939199df969784df819780849780b2c1dcc3c3dcc2">[email protected]</a>
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 command 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 complete 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>

Here's 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"
  }

Here are the steps I've taken so far that have not resolved the issue:

  1. Attempted to delete the node_modules folder
  2. Attempted to delete the package-lock.json file
  3. Reinstalled npm dependencies by running this command: npm install

Any advice on how to solve these problems would be greatly appreciated.

Answer №1

After doing some research, I came across a solution on a Github Issue page: https://github.com/npm/cli/issues/2119

At the time, my npm version was 7.0.8. Following the advice given by mvyunko in the issue, I executed the following commands:

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

Upon completing the commands, my npm version was successfully downgraded to 6.14.8, resolving the installation error I was facing.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Unable to use onSubmit with enter key in render props (React)

I am looking to include a button within a form that can trigger the onSubmit event when the user presses the Enter key. Here is an example of a functional solution: <form onSubmit={() => console.log('ok')}> <button type="submi ...

The Material UI Popover is appearing outside the designated boundaries

In my app, I am using the code below to implement a react-dates picker controller inside a popover element. The functionality works well in most scenarios, but there is an issue when the button triggering the popover is located at the bottom of the screen, ...

Rearrange the elements in an array containing objects

I am working with an array of objects: const array = [ { id: "5a2524432b68c725c06ac987", customOrder: 1, name: "One", }, { id: "5a2524432b68sgs25c06ac987", customOrder: 2, name: "Two", }, { id: "5a252wfew32b68c725c06a ...

Displaying column data in a popup modal using DataTables

I am facing an issue with displaying a long string from a column in my table in a popup modal. Upon clicking the button to launch the modal, instead of opening the modal, the page refreshes and nothing is logged to the console. Below is the HTML code for ...

What steps can be taken to modify this jQuery code so that any changes made are also saved to localStorage

I have successfully used jQuery to change the background color of all my divs with the same class (userNumber1) when I check its checkbox. However, I am now looking for a way to save these changes to localStorage, so that they persist each time the page is ...

What is the best way to call the `postMessage()` function within my XHR callbacks?

The uploads are working smoothly, but I'm facing issues with the progress and load events callbacks My WebWorker JavaScript file, UploadFileWorker.js, contains the following code: function uploadFile(url, m) { var f = m.file; var fd = new Fo ...

Guide to incorporating external CSS and JavaScript into an Angular 2 project with Express.js and Node.js

As a newcomer to Angular2 and NodeJs, I am eager to learn how to integrate external CSS and JS in an Angular2 and Nodejs express app. Specifically, I am looking to integrate a bootstrap admin theme into my Nodejs application. The screenshots below provide ...

Creating a dynamic default selection in a drop-down list using JQuery

While constructing a DataTable, everything was rendering perfectly until I encountered an issue with one of the columns. I needed to render a select/drop-down list and set a default selected value. After some trial and error, I was able to render the list ...

Revising variables in Java Script

How can I shuffle a list of variables in JS and maintain the order while changing their values? The following code snippet demonstrates what I am trying to achieve. <p id="demo"></p> <script> var gen = "male "; var race = "white"; var ...

The Angular service/value is failing to retrieve the updated variable from the $(document).ready() function

Currently, I'm facing an issue with my Angular service/value. It seems to be grabbing the original variable instead of the new one that is supposed to be inside $(document).ready(). Here's the relevant code snippet: var app = angular.module("app ...

How to filter jQuery DataTables by column using comparison operators

Recently, I've been utilizing the amazing DataTables jQuery plugin along with the filter plug in. But now, I find myself pondering if there's a way to filter table columns by row using a comparison operator (such as '<', '>&a ...

JavaScript Truthy and Falsy Tutorial on Codecademy

Could someone kindly clarify why this code is not functioning correctly? let defaultName; if (username) { defaultName = username; } else { defaultName = 'Stranger'; } This code snippet was found in the JavaScript section on Codecademy, but a ...

The jQuery form validation feature surprisingly doesn't take into account the value of the submit button

I have implemented jQuery form validation from Here is an example from demo.html <form id="form-signup_v1" name="form-signup_v1" method="get" class="validation-form-container"> <div class="field"> <label for="signup_v1-username">Fir ...

Generating a chart using solely the existing data components (values)

I have the following arrays: const elements = ['12345', '12346', '12347', '12348', '12349', '12350']; const fruits = ['Apple', 'Ball']; I want to create a Map using array ele ...

Interacting with a C# Web Service Using JQuery

I've set up a JSON web service in C# and I'm working on creating a custom HTML page to interact with it. http://localhost:25524/DBService.svc/json/db=TestDB/query=none When I input this URL into my browser, I expect to receive JSON formatted da ...

retrieving information from a data attribute

When setting a data attribute for a user on a link, the code looks like this: <input type="button" class="btn" data-user={"user": "<%= @user.name %>"} value="Start" id="game"> Upon listening for the click event in the JavaScript function, co ...

Tips for resolving the error when setting up @ngrx/store?

I'm encountering an issue during the installation of @ngrx/store. Is there anyone who can assist me in resolving this error? PS C:\Users\Welcome\ngrx-test> npm install @ngrx/store npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to re ...

What is the best way to locate the textbox ID that is closest to a checkbox using jQuery

I've generated a dynamic datatable using jQuery with checkboxes in the first column and textboxes in the last column. I want to clear the value of the textbox when a user unchecks the corresponding checkbox. I tried using the closest function, but it& ...

The initialization of a static member in a JS class occurs prior to the loading of the cdn

After declaring this class member, I encountered the issue stating that MenuItem is not defined. It appears that the class initialization occurs before React or Material-UI finishes loading (I am currently loading them from their CDN using straight < ...

Having trouble creating an app with Angular CLI: Encountered an issue with parsing JSON input, near the end of the input string '...bgwj8Xr2oElY7PTvOKwwu&#

I'm stuck trying to figure out where I went wrong. Initially, I had trouble getting NPM to install Angular as it kept timing out and throwing errors. Eventually, I managed to successfully install Angular after installing Yarn. However, now the Angula ...