If you’re looking to get started with Angular, one of the best ways to do that is to install it on your own Ubuntu server. This will allow you to test your app on different browsers like Google Chrome and Mozilla Firefox.
In this guide, we’ll show you how to install Angular on Ubuntu 20.04. The same procedure works on Ubuntu 22.04 as well. We’ll also cover some basic steps for getting started with Angular development. So, whether you’re a beginner or an experienced developer, this guide is for you!
In order to follow this tutorial, you will need a few things. Here’s what you need:
- Your VPS needs to have a non-root user with sudo privileges for running commands. You can learn more about how to set this up by reading our setup guide.
- System requirements: CPU: 2 cores CPU, Speed: 2GHz, RAM Memory: 2GB, Disk Space: 15GB.
Updating Ubuntu’s Repository
Before you begin to install Angular, it is important that you make sure your Ubuntu server is up-to-date. To do that, open up a terminal window by pressing Ctrl+Alt+T on your keyboard and then run the following command:
sudo apt update -y
We will install Angular using NVM (Node Version Manager) so we can switch Node.js versions easily without breaking anything in the process. We must install Node.js to use NVM, so let’s install it first.
Run the curl command below to add Nodesource’s Node.js repository to your system. Nodesource’s Node.js repository allows us to get the latest stable release of Node.js easily and quickly. It is a third-party software repository for installing Node.js on Debian, Ubuntu and other Linux GNU/Linux distributions, including Debian and Ubuntu derivatives such as Mint, elementaryOS, and Zorin OS .
curl -sL https://deb.nodesource.com/setup_14.x | sudo bash -
Run the curl command below to install Node.js on your system.
sudo apt install nodejs -y
Run the sudo npm install npm@latest -g command to install npm latest version globally on your computer.
sudo npm install npm@latest -g
Verify that you are using npm v8.x by running the following command.
Installing Angular on Ubuntu
Now that you have NVM installed on Ubuntu, you can install Angular easily by running the below command.
sudo npm install -g @angular/cli
Well, for starters, it is not a typo! The -g stands for Global. Global means that the command affects all of the Angular Applications on your computer. For example, if you installed angular globally, you would be able to use the angular-cli command in any directory.
When we installed Angular through NPM, it was locally installed for your use in just one directory. Usually, this is fine, but there may be cases where you want all your Angular projects to share the same version of Angular and if that’s not already confusing enough – sometimes you might even need different versions of Angular for different projects!
CLI stands for Command Line Interface. An interface is simply another computer program (the Command-Line), that allows humans to interact with it using text commands (for example).
The angular/cli package contains the code for our Angular command-line tool! So, when we run angular-cli in a directory with an Angular application in it, this command-line tool does its magic.
After installation, run this command to check the version of Angular you have installed. Ng is an abbreviation of Angular. Ng was introduced with the release of version 1.0. You can find Ng in many places like source code comments, online tutorials, etc.
You will get the following output. You can now open up your favorite IDE and develop many amazing things using the Angular framework. So that’s it! This is how you install Angular on Ubuntu 20.04.
In this guide, we have installed Angular on Ubuntu GNU/Linux using NVM and Node.js. We have also checked the version of Angular that you have just installed with the ng command.
Thank you for reading! Feel free to leave us your feedback in the comments section below if you like what you’ve read, or even if you don’t. We love to hear from you!