Cyberithub

How to Install Bower on Ubuntu 20.04 LTS (Focal Fossa)

Advertisements

In this article, I will take you through the steps to install bower on Ubuntu 20.04 LTS (Focal Fossa). Bower is a free and open source package manager for the web. It is mostly used for front-end package management. Bower can manage components that contain HTML, CSS, JavaScript, fonts or even image files. Bower doesn’t concatenate or minify code or do anything else - it just installs the right versions of the packages you need and their dependencies. More on Bower official website.

How does Bower works 

Bower works by fetching and installing packages from all over, taking care of hunting, finding, downloading, and saving the stuff you’re looking for. Bower keeps track of these packages in a manifest file called bower.json. How you use packages is up to you. Bower provides hooks to facilitate using packages in your tools and workflows.

How to Install Bower on Ubuntu 20.04 LTS (Focal Fossa)

How to Install Bower on Ubuntu 20.04 LTS (Focal Fossa)

Also Read: How to Install Grunt on Ubuntu 20.04 LTS Using 5 Easy Steps

Step 1: Prerequisites

a) You should have a running Ubuntu 20.04 LTS Server.

b) You should have sudo or root access to run privileged commands.

c) You should have apt utility available in your System.

 

Step 2: Update Your Server

In the very first step, you need to update the Server by using sudo apt update command as shown below. This will sync your System packages with the latest available versions.

cyberithub@ubuntu:~$ sudo apt update
Hit:1 http://in.archive.ubuntu.com/ubuntu focal InRelease
Hit:2 http://in.archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:3 http://in.archive.ubuntu.com/ubuntu focal-backports InRelease
Hit:4 https://dl.google.com/linux/chrome/deb stable InRelease
Get:5 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Get:6 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages [1,637 kB]
Get:7 http://security.ubuntu.com/ubuntu focal-security/main i386 Packages [473 kB]
Get:8 http://security.ubuntu.com/ubuntu focal-security/main Translation-en [278 kB]
Get:9 http://security.ubuntu.com/ubuntu focal-security/main amd64 DEP-11 Metadata [40.7 kB]
Get:10 http://security.ubuntu.com/ubuntu focal-security/main amd64 c-n-f Metadata [10.8 kB]
Get:11 http://security.ubuntu.com/ubuntu focal-security/restricted amd64 Packages [1,098 kB]
Get:12 http://security.ubuntu.com/ubuntu focal-security/restricted Translation-en [156 kB]
Get:13 http://security.ubuntu.com/ubuntu focal-security/universe i386 Packages [557 kB]
Get:14 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages [712 kB]
Get:15 http://security.ubuntu.com/ubuntu focal-security/universe Translation-en [129 kB]
Get:16 http://security.ubuntu.com/ubuntu focal-security/universe amd64 DEP-11 Metadata [66.9 kB]
Get:17 http://security.ubuntu.com/ubuntu focal-security/universe amd64 c-n-f Metadata [14.7 kB]
Get:18 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 DEP-11 Metadata [2,464 B]
Fetched 5,289 kB in 4s (1,356 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
13 packages can be upgraded. Run 'apt list --upgradable' to see them.

If any of the packages needs to be upgraded then you can run sudo apt upgrade command as shown below.

cyberithub@ubuntu:~$ sudo apt upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following package was automatically installed and is no longer required:
libfwupdplugin1
Use 'sudo apt autoremove' to remove it.
The following NEW packages will be installed:
linux-headers-5.15.0-43-generic linux-hwe-5.15-headers-5.15.0-43 linux-image-5.15.0-43-generic linux-modules-5.15.0-43-generic
linux-modules-extra-5.15.0-43-generic
The following packages will be upgraded:
firefox firefox-locale-en libldb2 libmysqlclient21 libsmbclient libsnmp-base libsnmp35 libwbclient0 linux-generic-hwe-20.04
linux-headers-generic-hwe-20.04 linux-image-generic-hwe-20.04 python3-ldb samba-libs
13 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.
13 standard security updates
Need to get 170 MB of archives.
After this operation, 565 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y

 

Step 3: Install Node.js

Since you are going to work on Node.js projects, it is imperative to have it installed in your System. In case, it is not installed you can run sudo apt install nodejs command to download and install the package along with all its dependencies from Ubuntu Repo.

cyberithub@ubuntu:~$ sudo apt install nodejs
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
libfwupdplugin1
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
libc-ares2 libnode64 nodejs-doc
Suggested packages:
npm
The following NEW packages will be installed:
libc-ares2 libnode64 nodejs nodejs-doc
0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
Need to get 6,807 kB of archives.
After this operation, 30.7 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
......................................

 

Step 4: Install NPM

Since we are going to install Bower from the NPM package manager, it is necessary to have this tool installed in your System. In case it is not installed, you can install it by using sudo apt install npm command as shown below. This command will download and install the package along with all its dependencies from Ubuntu repo.

cyberithub@ubuntu:~$ 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:
libfwupdplugin1
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
binutils binutils-common binutils-x86-64-linux-gnu build-essential dpkg-dev fakeroot g++ g++-9 gcc gcc-9 gyp javascript-common libalgorithm-diff-perl
libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan5 libatomic1 libbinutils libc-dev-bin libc6-dev libcrypt-dev libctf-nobfd0 libctf0 libfakeroot
libgcc-9-dev libitm1 libjs-inherits libjs-is-typedarray libjs-psl libjs-typedarray-to-buffer liblsan0 libnode-dev libpython2-stdlib libpython2.7-minimal
libpython2.7-stdlib libquadmath0 libssl-dev libstdc++-9-dev libtsan0 libubsan1 libuv1-dev linux-libc-dev make manpages-dev node-abbrev node-ajv
..........................................

 

Step 5: Install Bower

Finally install Bower through NPM by using sudo npm install -g bower command as shown below.

cyberithub@ubuntu:~$ sudo npm install -g bower
/usr/local/bin/bower -> /usr/local/lib/node_modules/bower/bin/bower
+ bower@1.8.14
added 1 package from 1 contributor in 3.332s

To check the currently installed bower version you can use bower --version command as shown below.

cyberithub@ubuntu:~$ bower --version
1.8.14

 

Step 6: Install a Package 

Now that Bower package manager is installed, it is time to test it by installing a package called jquery. You can install this package by simply using bower install jquery command as shown below.

NOTE:

Please note here that since bower runs over git, it is important to have git pre installed in your system before even try to use the bower package manager.
cyberithub@ubuntu:~$ bower install jquery
bower jquery#* not-cached https://github.com/jquery/jquery-dist.git#*
bower jquery#* resolve https://github.com/jquery/jquery-dist.git#*
bower jquery#* download https://github.com/jquery/jquery-dist/archive/3.6.0.tar.gz
bower jquery#* extract archive.tar.gz
bower jquery#* resolved https://github.com/jquery/jquery-dist.git#3.6.0
bower jquery#^3.6.0 install jquery#3.6.0

jquery#3.6.0 bower_components/jquery

Leave a Comment