LinuxCommandLibrary

bower

Manage front-end web dependencies

TLDR

Install a project's dependencies, listed in its bower.json

$ bower install
copy

Install one or more packages to the bower_components directory
$ bower install [package] [package]
copy

Uninstall packages locally from the bower_components directory
$ bower uninstall [package] [package]
copy

List local packages and possible updates
$ bower list
copy

Create a bower.json file for your package
$ bower init
copy

Install a specific dependency version, and add it to bower.json
$ bower install [local_name]=[package]#[version] --save
copy

Display help for a specific command
$ bower help [command]
copy

SYNOPSIS

bower <command> [<options>]

Common commands include:
bower install
bower search
bower list
bower uninstall
bower update
bower init

PARAMETERS

--allow-root
    Allow running Bower as the root user, which is generally discouraged for security reasons.

--config.key
    Override a specific configuration value for the command (e.g., --config.directory=./assets).

--force
    Force the command to execute, bypassing certain checks or overwriting existing files.

--json
    Output results in JSON format, useful for scripting and programmatic interactions.

--loglevel level
    Set the verbosity of log messages to debug, info, warn, error, or silent.

--offline
    Work in offline mode, using only cached packages and avoiding network requests.

--production
    Install only production dependencies, skipping development-specific dependencies defined in bower.json.

-h, --help
    Display help information for a specific command or general Bower usage.

-v, --version
    Output the installed version of Bower.

DESCRIPTION

The bower command-line tool is a package manager designed specifically for web-oriented front-end dependencies such as JavaScript libraries, CSS frameworks, fonts, and images. Unlike traditional Linux commands that are part of the operating system core, Bower is an application installed via Node.js's package manager, npm, but it runs effectively within a Linux terminal environment. Its primary function is to fetch and install client-side packages and their dependencies into a specified project directory (commonly bower_components/), focusing on providing ready-to-use assets for web development. It was conceived to manage a flat dependency tree, avoiding the nested structures often seen in Node.js modules. While widely used in the past, Bower has largely been superseded by more modern front-end tooling like npm and Yarn for managing dependencies.

CAVEATS

The bower project is officially deprecated and no longer actively maintained. Its GitHub repository prominently displays a deprecation notice, advising users to migrate their front-end dependency management to npm or Yarn. This means Bower may not receive updates for new features, bug fixes, or security vulnerabilities. It relies on Node.js and npm for installation and operation. Its dependency resolution, while designed to be flat, can sometimes lead to version conflicts if not managed carefully, especially in projects with many dependencies.

INSTALLATION

Bower is installed globally via npm (Node.js Package Manager) using the command:
npm install -g bower
This command makes the bower executable available in your system's PATH, allowing you to run it from any directory in your Linux terminal.

TYPICAL WORKFLOW

A common workflow with Bower involves initializing a project with bower init, which creates a bower.json file to define project metadata and dependencies. Packages are then installed using bower install <package> --save, which fetches the package and adds it to the project's dependencies in bower.json. Installed packages are typically placed in the bower_components/ directory. These assets can then be directly linked in HTML files or integrated into a build pipeline using task runners like Gulp or Grunt to concatenate, minify, or process them.

HISTORY

Bower was developed by Twitter and first released in 2012. It quickly gained traction as a crucial tool for front-end web development, primarily because npm at the time was heavily focused on Node.js modules and back-end dependencies, leaving a significant gap for client-side assets. Bower filled this void by providing a dedicated solution for managing JavaScript libraries, CSS frameworks, and other static web components. Its architecture prioritized a flat dependency structure, which was perceived as simpler for front-end projects than the nested `node_modules` structure. However, as npm evolved to better support front-end packages (e.g., with improved dependency resolution, `package-lock.json`, and direct client-side package distribution), and with the rise of alternatives like Yarn, Bower's distinct advantages diminished. In 2017-2018, Bower's official maintainers announced its deprecation, encouraging developers to transition to npm or Yarn, which led to a significant decline in its usage and active development.

SEE ALSO

npm(1), yarn(1), git(1), node(1)

Copied to clipboard