Skip to content

Guide · Open source

How to use Bower: install, manage front-end packages and tips

Updated · written with AI from the project's own documentation and checked against our catalogue data

Bower is a command-line tool that downloads and tracks front-end packages such as JavaScript libraries and lists them in a bower.json file. This guide shows you how to install it, add and remove packages, and handle the setup issues the project's README calls out. It also explains where Bower fits today, since the README recommends other tools for new projects.

Bowerbower/bower · ★ 14.9k · MIT

Quick start

  1. 1Install Node.js, npm and git. Bower depends on Node.js and npm, and some packages need git. Install all three before continuing.
  2. 2Install Bower globally. Run npm install -g bower to put the bower command on your system.
  3. 3Install existing dependencies. In a project with a bower.json file, run bower install to fetch every listed package.
  4. 4Add a new package. Run bower install <package> --save to install a package and record it in bower.json.
  5. 5Remove a package. Run bower uninstall <package-name> to remove a locally installed package.
  6. 6Process packages with a build tool. Pass Bower components through a build tool such as Grunt or gulp rather than serving them statically, as the README recommends.

Check the prerequisites before you install Bower

Bower depends on Node.js and npm. You also need git installed, because some Bower packages require it to be fetched and installed.

  • Node.js
  • npm
  • git

Install Bower globally with npm

Bower is installed through npm. The README gives a single global install command.

$ npm install -g bower

Install the packages listed in bower.json

If your project already has a bower.json file, run bower install with no package name to install every dependency it lists.

# install dependencies listed in bower.json $ bower install

Add a package and save it to bower.json

To install a new package and record it in bower.json, add the --save flag. To pin a specific version, append #<version> to the package name.

# install a package and add it to bower.json $ bower install <package> --save # install specific version of a package and add it to bower.json $ bower install <package>#<version> --save

Remove a package

To uninstall a locally installed package, pass its name to bower uninstall.

$ bower uninstall <package-name>

Use Bower packages through a build tool

The README discourages using Bower components directly as static files, citing performance and security reasons. It suggests processing components with a build tool such as Grunt or gulp, then serving them concatenated or through a module loader such as RequireJS.

Bower packages are not tied to one build system, and the README notes that a component can use any asset type and any transport, such as AMD or CommonJS.

Avoid common setup problems

Several environments need extra setup. Check these if Bower fails to run as expected.

  • Never run Bower with sudo. The README says it is a user command and does not need superuser permissions.
  • On Ubuntu, you might need to link the nodejs executable to node. The README gives a symlink command for this.
  • On prezto or oh-my-zsh, add alias bower='noglob bower' or escape the # in version specifiers.
  • On Windows, install Git for Windows correctly, following the options shown in the README.
  • If Bower keeps asking for your SSH password with TortoiseGit, set the GIT_SSH environment variable to the TortoisePlink path, adjusting it if needed.
sudo ln -s /usr/bin/nodejs /usr/bin/node

Configure Bower with .bowerrc

Bower can be configured with JSON in a .bowerrc file. The full list of options is in the Bower configuration docs at bower.io/docs/config.

What people use it for

  • Maintaining an older front-end project that already lists its libraries in bower.json
  • Installing a specific version of a JavaScript library and recording it for the team
  • Keeping legacy front-end components working without adopting a bundler
  • Running Bower packages through Grunt or gulp, then serving them with RequireJS

Frequently asked questions

How do I install Bower?

Install Bower globally with npm by running npm install -g bower. You need Node.js, npm and git on your system first. The command is listed in the project's README.

What are the requirements for Bower?

Bower depends on Node.js and npm. Git must also be installed, because some Bower packages require it to be fetched and installed. On Windows, you need Git for Windows set up correctly.

Is Bower free to use?

Bower is released under the MIT licence and is open source. Check the repository's licence file for the full terms.

Is Bower still maintained, and should I use it for new projects?

The README says Bower is still maintained. It also recommends yarn, webpack or parcel for new front-end projects, so Bower is best suited to existing projects.

Why does Bower say I should not run it with sudo?

The README states that Bower is a user command and there is no need to run it with superuser permissions. Run it as your normal user instead.

What are good alternatives to Bower?

The README points to yarn, webpack and parcel for new front-end projects. npm is also a package manager that Bower itself depends on for installation.

New agent skills, repos and AI tools — every week

The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.

Our verdict

Bower suits developers maintaining an existing front-end project that already uses bower.json, or teams keeping older components working without a build system. If you are starting a new front-end project, the README recommends yarn, webpack or parcel instead, and you will need a separate bundler or build pipeline because Bower only manages packages.

Install options & downloads