webpack Installation


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