Bower is a popular package manager for web projects, facilitating the management of dependencies such as frameworks, libraries, assets, and utilities. Although the front-end landscape has evolved with alternatives like Yarn and npm gaining popularity, Bower still supports legacy projects or specific use cases. This guide provides a comprehensive walkthrough for installing Bower on CentOS/RHEL 9/8.

Advertisement

Prerequisites

  • A system running CentOS/RHEL 9/8
  • Sudo or root privileges
  • Basic command-line proficiency

Step 1: Install Node.js and NPM

Bower requires Node.js and npm (Node Package Manager) as a prerequisite. CentOS/RHEL repositories might not always offer the latest version of Node.js, so we’ll use NodeSource repositories to install a recent version.

  1. Add NodeSource Repository
  2. : First, you’ll need to add the NodeSource repository to your system. Depending on the version of Node.js you want to install, the command may vary. For the latest stable version, use:
    curl -sL https://rpm.nodesource.com/setup_20.x | sudo bash -
    

  3. Install Node.js and npm: Once the repository is added, you can install Node.js and npm with the following command:
    sudo yum install -y nodejs
    
  4. Verify Installation: Confirm that Node.js and npm are correctly installed by checking their versions:
    node -v
    npm -v
    

Step 2: Install Git

Bower requires Git to fetch packages from remote repositories. Most CentOS/RHEL systems come with Git pre-installed, but if yours doesn’t, install it by running:

sudo dnf install git

Verify Git installation by checking its version:

git --version

Step 3: Install Bower

With Node.js, npm, and Git installed, you can now proceed to install Bower. Bower is installed globally using npm:

sudo npm install -g bower

Step 4: Verify Bower Installation

To ensure Bower is installed correctly, check its version:

bower -v

This command should return the installed version of Bower, indicating that Bower is successfully installed on your system.

Step 5: Using Bower

With Bower installed, you can now use it to manage front-end dependencies for your web projects. Here’s a quick example to get started:

  1. Creating a New Project
  2. : Navigate to your project directory (or create a new one) and initialize a new Bower project:
    mkdir myproject
    cd myproject
    bower init
    

  3. Installing Packages: To install a package, like jQuery for example, run:
    bower install jquery --save
    

    The --save flag adds the package as a dependency in your project’s bower.json file.

Conclusion

You have successfully installed Bower on CentOS/RHEL 9/8. While Bower may not be the first choice for new projects in the ever-evolving front-end development landscape, it remains a useful tool for managing dependencies in projects where it is already in use or where its specific functionalities are needed. Remember to check the official Bower documentation for more advanced usage and tips on managing your web project dependencies efficiently.

Share.

1 Comment

Exit mobile version