This tutorial explains all the steps required to install Bower and manage dependent packages on Windows system for front-end based project development. The steps should be the same on Linux based systems. Using Yarn and Webpack or Parcel is the recommended solution to manage dependencies for all the front-end based projects since bower is marked as deprecated. We might still need bower in several cases.

In order to use bower, we need to define the packages in the manifest file bower.json in JSON format. After defining the packages, we can install the dependent packages.

Install Bower

We need Node.js already installed on the system before starting with Bower installation. You can follow How To Install Node.js On Windows to install Node.js on Windows system. After confirming that Node.js is installed, run the below-mentioned command to install bower globally.

npm install -g bower

It will show NPM warning as shown in Fig 1.

Fig 1

Create Manifest File

We can create the manifest file from the console using the below-mentioned command. It asks a few questions in order to generate the manifest file.

bower init? name <project name>? description <project description>? main file <main js file>? keywords <comma separated keywords>? authors <authors>? license <license>? homepage <project home page>? set currently installed components as dependencies? No? add commonly ignored files to ignore list? Yes? would you like to mark this package as private which prevents it from being accidentally published to the registry? (y/N)? would you like to mark this package as private which prevents it from being accidentally published to the registry? Yes

These commands also update the bower.json file and remove the package dependencies from it.

Publish as Package

We can also distribute and publish our project as a bower package (or component) so that others can install it as a package similar to how we are using the packages published by others.

In order to do so, first, publish the project to GitHub as a public repository and add a tag specifying the initial version following semver guidelines. The package must be publicly available at a GitHub endpoint. We can also use other Git version control service. Add the bower_components directory to the gitignore list.