webpack Getting started with webpack Installation

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

Prerequisites:

NodeJS and npm

There are two ways of installing Webpack: globally or per-project. It is best to have the dependency installed per-project, as this will allow you to use different versions of webpack for each project and don't require user to have installed webpack globally.

Installing per-project

Run the following command from the root folder of your project:

npm install webpack --save-dev

You can then run the webpack executable installed to node_modules:

./node_modules/.bin/webpack

Or create an NPM script in your package.json file, where you can omit the node_modules part - npm is smart enought to include that folder in its PATH.

// in package.json:
{
  ...
  "scripts": {
    "start": "webpack"
  },
  ...
}

// from terminal:
npm start

Installing globally

Run the following command at a prompt:

npm install webpack -g


Got any webpack Question?