What is bower?
Bower is a package manager for the web. It allows you to manage dependencies for your web projects, ensuring that you have the right versions of libraries and frameworks. Bower can handle front-end packages like JavaScript libraries, CSS frameworks, and more.
What are bower's main functionalities?
Installing Packages
This command installs the jQuery library into your project. Bower will download the package and place it in the `bower_components` directory.
bower install jquery
Listing Installed Packages
This command lists all the packages that are currently installed in your project. It provides a tree-like structure of dependencies.
bower list
Updating Packages
This command updates all the packages in your project to their latest versions, based on the versioning rules specified in your `bower.json` file.
bower update
Uninstalling Packages
This command removes the jQuery library from your project. Bower will delete the package from the `bower_components` directory.
bower uninstall jquery
Creating a bower.json File
This command initializes a new `bower.json` file in your project. It will prompt you for information about your project and its dependencies.
bower init
Other packages similar to bower
npm
npm (Node Package Manager) is a package manager for JavaScript, primarily used for managing Node.js packages. Unlike Bower, npm can handle both front-end and back-end packages, making it more versatile. npm also has a larger repository of packages compared to Bower.
yarn
Yarn is a package manager that doubles down as a project manager. It is an alternative to npm and offers faster performance, deterministic dependency resolution, and better security. Yarn can manage both front-end and back-end packages, similar to npm.
pnpm
pnpm is a fast, disk space-efficient package manager. It uses a content-addressable file system to store all files from all module directories on a disk. When using pnpm, packages are linked from a single content-addressable storage, which saves a lot of space and makes installation faster.
Bower
A package manager for the web
Bower offers a generic, unopinionated solution to the problem of front-end package management, while exposing the package dependency model via an API that can be consumed by a more opinionated build stack. There are no system wide dependencies, no dependencies are shared between different apps, and the dependency tree is flat.
Bower runs over Git, and is package-agnostic. A packaged component can be made up of any type of asset, and use any type of transport (e.g., AMD, CommonJS, etc.).
View complete docs on bower.io
View all packages available through Bower's registry.
Install
$ npm install -g bower
Bower depends on Node.js and npm. Also make sure that git is installed as some bower
packages require it to be fetched and installed.
Usage
See complete command line reference at bower.io/docs/api/
Installing packages and dependencies
$ bower install
$ bower install <package> --save
$ bower install <package>
Using packages
We discourage using bower components statically for performance and security reasons (if component has an upload.php
file that is not ignored, that can be easily exploited to do malicious stuff).
The best approach is to process components installed by bower with build tool (like Grunt or gulp), and serve them concatenated or using module loader (like RequireJS).
Uninstalling packages
To uninstall a locally installed package:
$ bower uninstall <package-name>
prezto and oh-my-zsh users
On prezto
or oh-my-zsh
, do not forget to alias bower='noglob bower'
or bower install jquery\#1.9.1
Running commands with sudo
Bower is a user command, there is no need to execute it with superuser permissions.
However, if you still want to run commands with sudo, use --allow-root
option.
Windows users
To use Bower on Windows, you must install
msysgit correctly. Be sure to check the
option shown below:
Note that if you use TortoiseGit and if Bower keeps asking for your SSH
password, you should add the following environment variable: GIT_SSH - C:\Program Files\TortoiseGit\bin\TortoisePlink.exe
. Adjust the TortoisePlink
path if needed.
Configuration
Bower can be configured using JSON in a .bowerrc
file. Read over available options at bower.io/docs/config.
Completion (experimental)
NOTE: Completion is still not implemented for the 1.0.0 release
Bower now has an experimental completion
command that is based on, and works
similarly to the npm completion. It is
not available for Windows users.
This command will output a Bash / ZSH script to put into your ~/.bashrc
,
~/.bash_profile
, or ~/.zshrc
file.
$ bower completion >> ~/.bash_profile
Support
Contributing
We welcome contributions of all kinds from anyone. Please take a moment to
review the guidelines for contributing.
Bower Team
Bower is made by lots of people across the globe, contributions large and small. Our thanks to everyone who has played a part.
Core team
Bower Alumni
License
Copyright (c) 2014 Twitter and other contributors
Licensed under the MIT License