HomeFrameworksNodeJSHow to Install Webpack for Module Bundling

How to Install Webpack for Module Bundling

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. If you are running an older version of Nodejs then the solution for you is described in this journal. This journal entry will help you upgrade your existing Nodejs installation.

#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.

RELATED ARTICLES

Most Popular