Categories: TutorialsUbuntu

How to Install AngularJS in Ubuntu 20.04/22.04

Javascript is a popular scripting language used to develop both frontend and backend applications. To make work of developing applications easier, Javascript frameworks were developed. The frameworks are collections of Javascript libraries that provide programmers with pre-written code for routine programming tasks. Frameworks are particularly beneficial for less experienced developers who are still learning the ropes in development. It allows them to develop clean and efficient code. Simply put, it helps save time and effort in developing applications.

One of most popular Javascript frameworks is Angular JS. This a modern Javascript framework initially developed by Misko Hevery and Adam Abrons, and later acquired and maintained by Google. It is a stable and superb framework for developing high-quality and dynamic applications. In this guide, we explore the installation of Angular JS on Ubuntu Focal Fossa ( Ubuntu 20.04 )

Step
Sponsored
1: Update Ubuntu

Straight off the bat, log in to your instance and update the package index as follows.

$ sudo apt update

With the package index updated, proceed to the next step.

Step 2: Install NodeJS on Ubuntu

Angular is a JavaScript framework. We therefore need to install the Javascript runtime environment on Ubuntu 20.04. Be sure that curl utility is installed as follows. If you already have curl installed, you can ignore this step.

$ sudo apt install -y curl

After that, download node setup from source using the following script. Execute the command:

$ curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -

After this, install nodeJS as shown:

$ sudo apt install -y nodejs

Thereafter, execute the command shown to install the latest version of npm.

$ sudo npm install npm@latest -g

Confirm the npm and node are installed with the command:

 $ npm -v
 $ node -v

Step 3: Install AngularJS

With npm is installed, we can proceed to install AngularJS on Ubuntu using then npm command:

$ sudo npm install -g @angular/cli

The installation will take a few minutes to complete. Once done , check the version of AngularJS as follows:

$ ng version

Sponsored

The above Angular CLI will be displayed.

Step 4: Create Angular Application

Now that Angular is successfully installed on the system, we can go ahead and create our first angular application. First, create an application with the command:

$ ng new hello-world

The above command creates a directory with the name hello-world that contains necessary files for an angular application.

Next, navigate into the app you just created above:

$ cd hello-world

Next, run the following command to compile your application.

$ ng serve

By default, the ng serve command runs the application on port 4200. To access your application visit the url http://localhost:4200.

You have successfully compiled and run an angular application.

There is an option to specify the host and port on which to run your application. In this case, I want to run my application on host 0.0.0 and port 8000. Use the command below:

$ ng serve --host 0.0.0.0 --port 8000

Conclusion

You can now develop web Applications using Angular on Ubuntu 22.04.

Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications including CCNA RS, SCP, and ACE. As an IT engineer and technical author, he writes for various websites.

Ubuntu Server Admin

Recent Posts

Welcome to the Ubuntu Weekly Newsletter 883

Welcome to the Ubuntu Weekly Newsletter, Issue 883 for the week of March 9 –…

12 hours ago

How to Install nvidia-smi on Ubuntu or Debian Linux

In this article, we will see how to install nvidia-smi on Ubuntu or Debian Linux.…

1 day ago

How to Install clang tool on Ubuntu or Debian Linux

In this article, we will see how to install clang tool on Ubuntu or Debian…

2 days ago

How to resolve Ubuntu 20.04 Container Signature Errors on Raspberry Pi ARM Devices

When working with Docker containers on Raspberry Pi devices, you might encounter frustrating signature verification…

3 days ago

How to fix DNS Resolution Issues with OpenVPN on Ubuntu 18.04

You’ve recently upgraded to Ubuntu 18.04 and found that your OpenVPN connection no longer resolves…

3 days ago

How to Fix Ubuntu 18.04 System Monitor Launch Issues

Have you ever tried to open System Monitor on your Ubuntu 18.04 system only to…

4 days ago