In this guide, we will illustrate how to install and use AngularJS on Ubuntu
AngularJS was a JavaScript-based open-source front-end web framework for developing single-page applications. It was maintained mainly by Google and a community of individuals and corporations.
It aimed to simplify both the development and the testing of such applications by providing a framework for client-side model–view–controller (MVC) and model–view–viewmodel (MVVM) architectures, along with components commonly used in web applications and progressive web applications.
AngularJS was used as the frontend of the MEAN stack, that consisted of MongoDB database, Express.js web application server framework, AngularJS itself (or Angular), and Node.js server runtime environment.
Installation
Just follow the steps below
- Update and upgrade Ubuntu system
sudo apt update && sudo apt upgrade
Install Node.js On Ubuntu
After that we will use npm(Node Package Manager) to install AngularJS .
npm is the default package manager for Node.JS on a Linux system. So, will install it on our Ubuntu system.
- Add the Node.JS repository. Also we will install Node.js 14 on Ubuntu since node.js 16 is not supported by Angular
curl -sL https://deb.nodesource.com/setup_14.x | sudo bash -
- Then install node.js on Ubuntu
sudo apt install nodejs -y
- Confirm your installation by checking the node.js version and npm version as shown below.
node -v
- The command above will also install npm JavaScript packge manager, So update the npm version.
sudo npm install npm@latest -g
Install AngularJS on Ubuntu
- Install AngulaJS on your system, Install the latest version of AngulaJS on Ubuntu using the below command
sudo npm install -g @angular/cli
The latest version of Angular CLI will be installed on ubuntu 20.04, 21.04 and18.04
- Check or verify the installed version of Angular by running:
ng version
NOTE:
You can install a specific version on Angular CLI on Ubuntu.
npm install -g @angular/cli@10 #Angular 10
npm install -g @angular/cli@9 #Angular 9
npm install -g @angular/cli@8 #Angular 8
Create a New Angular Application
- Now you can use the “ng“command to create a new angular application.
For Example: we will create a demo application called UnixcopVisitors using AngularJS.
ng new UnixcopVisitors
The command creates a directory UnixcopVisitors in the current directory with all the required files for the Angular application.
Serve the Angular Application
- After you created the angular app, go to the app directory then serve your application as shown below.
cd UnixcopVisitors
ng serve
- the access the application on the web using the URL http://localhost:4200 as shown below
NOTE:
Also you can change the host and port on which the application is running using:
ng serve --host 0.0.0.0 --port 8080
Conclusion
That’s it
We showed you how to install and use AngularJS on Ubuntu 20.04
Thanks….