Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

[email protected] requires a peer of webpack@^4.x.x but none is installed

Having a little trouble with React. Does anyone know how I can install the peer of webpack@^4.x.x?

This is the error I am recieving when I try to run

webpack-dev-server

in cmd. It just returns

[email protected] requires a peer of webpack@^4.x.x but none is installed. You must install peer dependencies yourself.
like image 548
Allan Avatar asked Jul 11 '18 20:07

Allan


People also ask

Is Webpack CLI required?

If you're using webpack v4 or later and want to call webpack from the command line, you'll also need to install the CLI.

What is Webpack CLI NPM?

webpack CLI provides a flexible set of commands for developers to increase speed when setting up a custom webpack project. As of webpack v4, webpack is not expecting a configuration file, but often developers want to create a more custom webpack configuration based on their use-cases and needs.

Is Webpack CLI a dev dependency?

This approach considers that since your production app (aka the bundle you built with Webpack) can just run by itself, it means you have no production dependencies. Thus, all dependencies are devDependencies .

Is it possible to install a peer of Webpack-CLI?

npm WARN [email protected] requires a peer of webpack@^4.x.x but none is installed. You must install peer dependencies yourself.

Should I install Webpack locally or via NPM?

Installing locally is what we recommend for most projects. This makes it easier to upgrade projects individually when breaking changes are introduced. Typically webpack is run via one or more npm scripts which will look for a webpack installation in your local node_modules directory:

What is Webpack CLI and how to use it?

webpack CLI is a CLI tool for providing a flexible set of commands for developers to increase speed when setting up a custom webpack project. As of webpack v4, webpack is not expecting a configuration file but often, developers want to create a more custom webpack configuration based on their use-cases and needs.

How do I install a beta version of Webpack?

If you are enthusiastic about using the latest that webpack has to offer, you can install beta versions or even directly from the webpack repository using the following commands: npm install --save-dev webpack@next npm install --save-dev webpack/webpack Take caution when installing these bleeding edge releases!


Video Answer


1 Answers

webpack-dev-server has Webpack as a peer dependency, which means that you are responsible for installing that yourself.

You could install the latest version of Webpack and add it to your devDependencies with the following command:

npm i -D webpack@latest

By writing webpack-dev-server you are also trying to use the globally installed version of that package. You can use the locally installed one instead by adding it to a script in your package.json:

{
  "scripts" : {
    "start": "webpack-dev-server"
  }      
}
like image 171
Tholle Avatar answered Sep 18 '22 16:09

Tholle