How to Install Bower on Ubuntu 16.04/18.04 Linux

This post will guide you how to install Bower on your Ubuntu Linux server. How do I install Bower Tool on Ubuntu Linux 16.04/18.04. How to use Bower to install a package on your Ubuntu system.

What is Bower?


Bower is a package manager for front-end libraries, it can be used to manage web site components, such as: frameworks, libraries, assets, and utilities. And Bower also can manage components that contain HTML, Css, JavaScript, fonts or even image files. Bower does not concatenate or minify code or do anything else. And it just installs the right versions of the packages you need and their dependencies. So It will keep to track of all the components and checks regularly for their updates. Bower use a manifest file called bower.json to keep track of these packages. And it use Git tool to install the required packages. So before installing Bower, you need to install node.js and git tools firstly.

Installing Git


As Bower need to use Git to install the packages on your Ubuntu Linux server, you need to make sure git tool is installed, type the following apt install command to install it:

$ sudo apt install git

Outputs:

devops@devops-osetc:~$ sudo apt install git
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libllvm6.0 x11proto-dri2-dev x11proto-gl-dev
Use 'sudo apt autoremove' to remove them.
Suggested packages:
git-daemon-run | git-daemon-sysvinit git-doc git-el git-email git-gui gitk gitweb git-cvs git-mediawiki git-svn
The following NEW packages will be installed:
git
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 3,907 kB of archives.
After this operation, 32.2 MB of additional disk space will be used.
Get:1 http://mirrors.aliyun.com/ubuntu bionic-security/main amd64 git amd64 1:2.17.1-1ubuntu0.4 [3,907 kB]
Fetched 3,907 kB in 2s (1,645 kB/s)
Selecting previously unselected package git.
(Reading database ... 221496 files and directories currently installed.)
Preparing to unpack .../git_1%3a2.17.1-1ubuntu0.4_amd64.deb ...
Unpacking git (1:2.17.1-1ubuntu0.4) ...
Setting up git (1:2.17.1-1ubuntu0.4) ...

You can run the following command to make sure git has been installed successfully on your Ubuntu system.

$ git --versions

Outputs:

devops@devops-osetc:~$ git --version
git version 2.17.1

Installing Nodejs And Npm


As Bower need to use Node.js and npm tools to manage all applications, you need to install both two packages on your Ubuntu system. Type the following command to install it:

$ sudo apt install npm
$ sudo apt install nodejs

Outputs:

devops@devops-osetc:~$ sudo apt install npm
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
libssl-doc
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
gyp javascript-common libc-ares2 libhttp-parser2.7.1 libjs-async
......
Need to get 9,782 kB/10.0 MB of archives.
After this operation, 42.2 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://mirrors.aliyun.com/ubuntu bionic/universe amd64 gyp all 0.1+20150913git1f374df9-1ubuntu1 [265 kB]
Get:2 http://mirrors.aliyun.com/ubuntu bionic/universe amd64 libjs-async all 0.8.0-3 [25.4 kB]
Get:3 http://mirrors.aliyun.com/ubuntu bionic/universe amd64 libjs-node-uuid all 1.4.7-5 [11.5 kB]
......
Setting up node-form-data (0.1.0-1) ...
Setting up node-request (2.26.1-1) ...
Setting up node-minimatch (3.0.4-3) ...
Setting up node-normalize-package-data (2.3.5-2) ...
Setting up node-ansi-color-table (1.0.0-1) ...
Setting up node-npmlog (0.0.4-1) ...
Setting up node-glob (7.1.2-4) ...
Setting up node-rimraf (2.6.2-1) ...
Setting up node-read-package-json (1.2.4-1) ...
Setting up node-fstream (1.0.10-1) ...
Setting up node-fstream-ignore (0.0.6-2) ...
Setting up node-tar (2.2.1-1) ...
Setting up node-gyp (3.6.2-1ubuntu1) ...
Setting up npm (3.5.2-0ubuntu4) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
devops@devops-osetc:~$

devops@devops-osetc:~$ sudo apt install nodejs
Reading package lists... Done
Building dependency tree
Reading state information... Done
nodejs is already the newest version (8.10.0~dfsg-2ubuntu0.4).
nodejs set to manually installed.
The following package was automatically installed and is no longer required:
libssl-doc
Use 'sudo apt autoremove' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Then you need to check if you have successfully installed NPM and node.js tools on your Ubuntu system with the following command:

$ npm --version

or

$ node --version

Outputs:

devops@devops-osetc:~$ npm --version
3.5.2
devops@devops-osetc:~$ node --version
v8.10.0

Installing Bower Using NPM


After installed NPM in the above step, you can try to install Bower with NPM tool on your system, just use the following command to install bower:

$ sudo npm install -g bower

After the installation process is completed, you need to check if the bower has installed successfully on your system with the following command:

$ bower --version

Outputs:

devops@devops-osetc:~$ node --version
1.8.2

Installing Packages Using Bower


If you want to install a package with Bower tool, you can use the following command syntax:

$ bower install <packageName>

Or

$ bower install <Git Endpoint>

For example, you want to install a package called bootstrap with Bower, just using one of the following commands:

$ bower install bootstrap

or

$ bower install https://github.com/twbs/bootstrap.git

Outputs:

devops@devops-osetc:~$ bower install bootstrap
bower not-cached git://github.com/twbs/bootstrap.git#*
bower resolve git://github.com/twbs/bootstrap.git#*

bower download https://github.com/twbs/bootstrap/archive/v3.3.7.tar.gz
bower progress bootstrap#* received 0.2MB of 4.0MB downloaded, 2%
bower progress bootstrap#* received 0.3MB of 4.0MB downloaded, 3%
bower progress bootstrap#* received 0.5MB of 4.0MB downloaded, 4%
......
bower progress bootstrap#* received 4MB of 4.0MB downloaded, 100%
......

If you want to search Bower packages and find the registered package names for you favorite projects, you can directly visit Bower Search packages page.

If you want to get more information about bower, you can use the following command:

$ bower --help

Outputs:

devops@devops-osetc:~$ bower --help

Usage:

bower 
Commands:

cache Manage bower cache
help Display help information about Bower
home Opens a package homepage into your favorite browser
info Info of a particular package
init Interactively create a bower.json file
install Install a package locally
link Symlink a package folder
list List local packages - and possible updates
login Authenticate with GitHub and store credentials
lookup Look up a single package URL by name
prune Removes local extraneous packages
register Register a package
search Search for packages by name
update Update a local package
uninstall Remove a local package
unregister Remove a package from the registry
version Bump a package version

Options:

-f, --force Makes various commands more forceful
-j, --json Output consumable JSON
-l, --loglevel What level of logs to report
-o, --offline Do not hit the network
-q, --quiet Only output important information
-s, --silent Do not output anything, besides errors
-V, --verbose Makes output more verbose
--allow-root Allows running commands as root
-v, --version Output Bower version
--no-color Disable colors

See 'bower help ' for more information on a specific command.

Conclusion


You should know that how to install Bower tool on Ubuntu 16.04 or 18.04 from this guide, and you also know that how to install a package with Bower on your system. If you want to see more information about Bower, you can go the official web site of Bower directly.

You might also like:

Sidebar



back to top