Angular CLI on Linux
As Angular is a cross-platform tool, the Angular CLI has a very important role in developing front-end, mobile applications, and desktop applications. It is more speedy than the GUI based Angular on any platforms. You can use the Angular CLI for code reusability, increase the loading speed, and make the performance better. Moreover, developers feel comfortable working on the Angular CLI because of its command-line interface, which is faster and easily executable.
As Linux is well known for speedy performance and doesn’t require high maintenance, the Angular CLI works perfectly on any Linux distributions. The CPU, Memory, and other hardware compatibility issues are rarely found on Linux while installing the Angular CLI. In this post, we will learn how to install the Angular CLI on different Linux distributions.
Using the Angular CLI instead of the graphical Angular doesn’t only boost your performance, rather it has a subtle ability to make your code clean and professional. In this post, we will see how you can install the Angular CLI on various Linux distributions.
1. Install Angular CLI on Debian and Ubuntu Linux
On Ubuntu and other Debian Linux systems, installing the Angular CLI is pretty simple and straight forward. First, all you need to do is install the Node Version Manager (NVM) on your Ubuntu machine. Later, we will use the NVM tool to install the Angular CLI on Ubuntu.
Step 1: Install NVM on Ubuntu
First, run the following aptitude command given below to update your package repositories. Then run the cURL command to download the NVM bash script. If you don’t have the cURL installed inside your system, first install the cURL.
sudo apt-get install curl sudo apt update curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
Now, run the following
bashrc command and NVM command to install the node version manager tool inside your Linux system.
source ~/.bashrc nvm install node
Step 2: Install Angular CLI Via NPM
Till now, we have successfully installed the NVM tool on our Debian system. Finally, we are about to install the Angular CLI on our Ubuntu system. Here, I am going to install the latest version of Angular CLI on our Linux system. Run the following node package manager (NPM) command given below to install the latest global version of Angular CLI on your Ubuntu Linux system.
npm install -g @angular/cli
If you want to install any other previous version of Angular CLI, you can run one of the following commands-lines given below. The version number is mentioned right after the
npm install -g @angular/cli@8 npm install -g @angular/cli@9 npm install -g @angular/cli@10
After the installation of Angular CLI is done, you can now check the version of your Angular CLI to ensure that the tool is installed successfully inside your machine.
If you are a newbie in the Angular CLI, you run the following help command to get an idea about the syntaxes of the Angular CLI.
Step 3: Remove Angular CLI from Ubuntu
There might be some reasons or errors that might cause you to uninstall the Angular CLI from your Ubuntu Linux. Now, to remove the Angular CLI from your Debian and Ubuntu machine, you can run the following command-lines given below.
npm uninstall -g angular-cli npm uninstall -g @angular/cli npm cache clean npmcache clean --force
2. Install Angular CLI on Fedora and RedHat
Step 1: Install NodeJS on Fedora and RedHat Linux
To install the Angular CLI on our Red Hat and Fedora Linux, we need to install the NodeJS on our system. The NodeJS and the NPM tools will make a perfect environment for the Angular CLI. Now, run the following cURL command in your Linux terminal to get the NodeJS and NPM tools. Make sure that the CURL is installed inside your system.
curl -sL https://rpm.nodesource.com/setup_12.x | sudo -E bash -
Now, run the following YUM command to finish the installation of NodeJS. The YUM command works on both Fedora and Red Hat Linux.
sudo yum install nodejs
You can now run the following command-lines given below to ensure whether the NODE and NPM are installed correctly on your system or not.
node --version npm --version
Step 2: Install Angular CLI on Fedora and Red Hat Linux
As we have installed the NPM tool on our Linux system, we will now use the NPM commands to install the Angular CLI. Installing the Angular CLI is via the NPM is a very simple task. You need to run the following NPM command given below on your Linux terminal to install the latest global version of Angular CLI on your Linux system.
sudo npm install -g @angular/cli
If you need to install another older version of Angular CLI on your system, you can run any of the following command-lines given below on your terminal. The version numbers are assigned right after the
npm install -g @angular/cli@9 npm install -g @angular/cli@8 npm install -g @angular/cli@7
Now, after the installation of Angular CLI is done, we can check the version of the Angular CLI to make sure that the package is installed successfully inside our machine.
3. Angular CLI on Arch Linux
As we all know that, installing any packages on Arch and Arch-based Linux is a little bit different than any other Linux distributions; there are no exceptions here as well. In this case, first, we have to install the NodeJS inside our Arch Linux system. Then we will install the NPM tool on our system.
Step 1: Install NodeJS and NPM on Arch Linux
Here, I am using Manjaro Linux to demonstrate installing the Angular CLI on Arch Linux. All the command-lines would run smoothly on any other Arch-based Linux distributions. Now, run the following Pacman command-lines given below to install the Nodejs and NPM on your Arch Linux.
sudo pacman -Syyu nodejs sudo pacman -S npm
Then, run the following command-line given below to update your node package manager (NPM) environment. Here, the
-g syntax symbolizes that the global version of NPM is being installed and updated.
npm update -g
After the installation is done, you can now run the following command-lines given below to check the Node and NPM versions to ensure that the NODE and NMP are installed successfully inside your Arch Linux system.
node -v nmp -v
Step 2: Install Angular CLI on Arch Linux
As we have installed the NodeJS and the NPM on our Arch Linux system, now, in this step, we will use the NPM command to install the Angular CLI on our Arch Linux system. Run the following command line given below to install the latest and global version of Angular CLI on your Arch Linux system.
sudo npm install -g @angular/cli
Finally, when the installation of Angular CLI is done, you can now run the following
ng command on your Linux terminal to ensure that the Angular CLI is installed correctly on your Arch Linux system.
If you are more interested in the Angular CLI on Arch Linux, you can visit this link to find more pieces of information about the Angular CLI on Arch Linux.
Get Started With Angular CLI
Finally, we have successfully installed the Angular CLI on our Linux distributions. Now, it’s time to take a tour. Before doing anything, we should add the Angular port in the firewall rule. If you are using the UFW firewall, run the following commands to add port 4200 into the firewall list.
sudo ufw enable sudo ufw allow 4200/tcp sudo ufw reload
If you are using Fedora, Red Hat Linux, and other Linux distributions, you use the Firewalld command to enable port 4200 for your environment. First, enable the Firewalld on your Linux system.
systemctl status firewalld systemctl enable firewalld sudo firewall-cmd --reload
Now, add the rule to the Firewalld settings. Then restart the Angular CLI system.
firewall-cmd --add-port=4200/tcp firewall-cmd --list-all
Now, make sure that the localhost server is functional on your Linux system. Then, type the URL given below into your web-browser’s address bar, then hit the Enter button. To avoid any server-level confliction, make sure that you don’t have both the Apache and the Nginx server installed in the same machine.
In this post, I have described how you can install the NodeJS and NPM on your Linux system, and later you can install the Angular CLI through the NPM tool. As Linux users are more comfortable with the command-line based interface, so no doubt, it would be easy to learn and apply the Angular CLI for the Linux users.
If you like this post, please share it with your friends and the Linux community. You can also write down any comments regarding this post in the comment section.