Journal for Developers

How to Install Webpack for Module Bundling

0 158

Installation

This journal will guide you through the various processes to install webpack.

Pre Requisites

Before we begin, make sure you have a fresh version of Node.js installed. The current Long Term Support (LTS) release is an ideal starting point. You may run into a variety of issues with the older versions as they may be missing functionality webpack and/or its related packages require.

#Local Installation

To install the latest version of webpack use the following command

npm install --save-dev webpack

However, if you wish to install the specific version of webpack then in that case you can use the following command:

npm install --save-dev webpack@<version>

Installing webpack locally is generally recommended for most of the projects. This makes it easier to upgrade projects individually when breaking changes are introduced. Typically webpack is run via one or more npm scriptswhich will look for a webpack installation in your local node_modules directory:

"scripts": {
   "start": "webpack --config webpack.config.js"
}

#Global Installation

The following NPM installation will make webpack available globally on your development machine:

npm install -g webpack

NOTE: You can also use -global as the parameter

#Bleeding Edge Installation

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 webpack@beta
npm install webpack/webpack#<tagname/branchname>

NOTE: You have to be very careful when installing these bleeding edge releases! They may still contain bugs and therefore it is not advised to be used in production.

Subscribe to our Journal

Join our mailing list to receive the latest news and updates from our team.

You have Successfully Subscribed!