How to Install Angular CLI on Ubuntu 18.04/16.04 LTS

In this article, we are going to How to Install Angular CLI on Ubuntu 18.04/16.04 LTS or any other cloud platform like Amazon EC2, Azure VM, Google Cloud Compute, etc. with preinstalled Ubuntu OS.

Introduction:

Angular is most popular open source Google-developed JavaScript framework. It is used to design client-side web and mobile application.

Why You Should Use Angular:

MVC Architecture: It is Open Source framework MVC based framework and advanced Typescript/JavaScript support.

Supports All Platforms: It has ability to build applications on any platforms like Web, Mobile and native mobile.

Beautiful UI and UX: Using Angular you can develop Featured Rich, Amazing UI and Single Page application.

Large Community: Angular became extremely among developers, largely available training materials, forums and third-party tools and can find solution of every issues.

Prerequisite:

  • Ubuntu 18.04 LTS 64 bit with Minimum Installation.
  • Minimum 2 CPU and 4 GB RAM.
  • Open Firewall Ports 3000 and 4200.

First, make sure that all your system packages are up-to-date, Run below commands to update/upgrade system packages.

$ sudo apt-get update
$ sudo apt-get upgrade

Install the curl

$ sudo apt-get install curl

Step 1: Installing Node.js and NPM

Before Installing Angular CLI on Ubuntu 18.04 LTS , First we need to Install latest NodeJS and Node Package Manager(NPM).

First, Add Node.js and NPM from NodeSource Repository

$ curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -

Output:

+ curl -sLf -o /dev/null 'https://deb.nodesource.com/node_12.x/dists/xenial/Release'

## Adding the NodeSource signing key to your keyring...

+ curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -

OK

## Creating apt sources list file for the NodeSource Node.js 12.x repo...

+ echo 'deb https://deb.nodesource.com/node_12.x xenial main' > /etc/apt/sources.list.d/nodesource.list

+ echo 'deb-src https://deb.nodesource.com/node_12.x xenial main' >> /etc/apt/sources.list.d/nodesource.list

## Running `apt-get update` for you...

+ apt-get update

Hit:1 http://azure.archive.ubuntu.com/ubuntu xenial InRelease

Hit:2 http://azure.archive.ubuntu.com/ubuntu xenial-updates InRelease

Hit:3 http://azure.archive.ubuntu.com/ubuntu xenial-backports InRelease

Hit:4 http://security.ubuntu.com/ubuntu xenial-security InRelease

Get:5 https://deb.nodesource.com/node_12.x xenial InRelease [4,584 B]

Get:6 https://deb.nodesource.com/node_12.x xenial/main amd64 Packages [764 B]

Fetched 5,348 B in 0s (11.1 kB/s)

Reading package lists... Done

## Run `sudo apt-get install -y nodejs` to install Node.js 12.x and npm

## You may also need development tools to build native addons:

     sudo apt-get install gcc g++ make

## To install the Yarn package manager, run:

     curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -

     echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

     sudo apt-get update && sudo apt-get install yarn

Install Node JS and NPM using below command,

$ sudo apt-get install -y nodejs

Output:

The following NEW packages will be installed:

  nodejs

0 upgraded, 1 newly installed, 0 to remove and 32 not upgraded.

Need to get 17.6 MB of archives.

After this operation, 88.1 MB of additional disk space will be used.

Get:1 https://deb.nodesource.com/node_12.x xenial/main amd64 nodejs amd64 12.14.1-1nodesource1 [17.6 MB]

Fetched 17.6 MB in 0s (35.7 MB/s)

Selecting previously unselected package nodejs.

(Reading database ... 191824 files and directories currently installed.)

Preparing to unpack .../nodejs_12.14.1-1nodesource1_amd64.deb ...

Unpacking nodejs (12.14.1-1nodesource1) ...

Processing triggers for man-db (2.7.5-1) ...

Setting up nodejs (12.14.1-1nodesource1) ...

Step 2: Check Node.js and NPM Version on Ubuntu

After installation, check Node.js version by entering below command,

$ node --version

Output:

$ node --version
v12.14.1

To Check NPM version.

$ npm --version

Output:

$ npm --version
6.13.4

Step 3: Install Angular CLI on Ubuntu

Run below command to install angular CLI.

$ sudo npm install -g @angular/cli

Output

/usr/bin/ng -> /usr/lib/node_modules/@angular/cli/bin/ng

> @angular/[email protected] postinstall /usr/lib/node_modules/@angular/cli

> node ./bin/postinstall/script.js

? Would you like to share anonymous usage data with the Angular Team at Google under

Google’s Privacy Policy at https://policies.google.com/privacy? For more details and

how to change this setting, see http://angular.io/analytics. Yes

+ @angular/[email protected]

added 251 packages from 186 contributors in 17.603s

Run below command to check install Angular Version.

$ ng --version

Sample Output:

Angular CLI: 8.3.23

Node: 12.14.1

OS: linux x64

Angular:

...

Package                      Version

------------------------------------------------------

@angular-devkit/architect    0.803.23

@angular-devkit/core         8.3.23

@angular-devkit/schematics   8.3.23

@schematics/angular          8.3.23

@schematics/update           0.803.23

rxjs                         6.4.0

Step 4: Creating new Angular Project

Run following command to create New Angular Project named test-project.

$ ng new test-project

Output:

.....
...... 
added 1167 packages from 1048 contributors and audited 19053 packages in 72.14s
23 packages are looking for funding
  run `npm fund` for details
found 0 vulnerabilities
    Successfully initialized git.

 Step 3: Running Angular Application

Once Project created successfully, navigate to project and Run your Application using ng server command.

$ cd test-project

$ ng serve

Output:

angular cli

To Access Angular Application on browser, enable the port 4200 in firewall or inbound rule in Cloud.

http://localhost:4200

Successfully we have performed install angular CLI on Ubuntu.

Conclusion:

We have covered, How to Install Angular CLI on Ubuntu, Commands to check version of node JS,NPM and Angular, Creating and running test project in Angular.

Related Articles:

How to Install Latest Node.js and NPM on Ubuntu 19.04,18.04/16.04 LTS

Shivdas Kanade

I am Shivdas Kanade working as DevOps Engineer. Passionate about Linux, Open Source and DevOps Tools. Believe in sharing knowledge.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Shares
Share via
Copy link