How to Install Angular CLI on CentOS 8

Angular is a popular open-source application development framework. It is highly extensible and used for developing mobile and web applications using TypeScript/JavaScript. It is designed for building small to large-scale applications from scratch. It provides an Angular CLI utility to create, manage, build and test Angular applications..

In this post, we will show you how to install Angular (CLI) on CentOS 8.

Prerequisites

  • A server running CentOS 8.
  • A root password is configured on your server.

Install Node.js

In order to install Angular, Node.js must be installed in your server. If not installed, you can install it with the following command:

curl -sL https://rpm.nodesource.com/setup_14.x | bash -
dnf install nodejs -y

Once the installation is completed, verify the installed version of Node.js with the following command:

node --version

Output:

v14.16.1

You can also verify the NPM version using the following command:

npm --version

Output:

6.14.12

Install Angular/CLI

Now, you can install the Angular/CLI by running the following command:

npm install -g @angular/cli

Once installed, verify the installed version of Angular/CLI with the following command:

ng --version

You should get the following output:

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / ? \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 11.2.7
Node: 14.16.1
OS: linux x64

Angular: 
... 
Ivy Workspace: 

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1102.7 (cli-only)
@angular-devkit/core         11.2.7 (cli-only)
@angular-devkit/schematics   11.2.7 (cli-only)
@schematics/angular          11.2.7 (cli-only)
@schematics/update           0.1102.7 (cli-only)

Create an Application with Angular

Angular/CLI provides an easier way to create and deploy an application in a production and local environment.

To create a new application named hello-world, run the following command:

ng new hello-world

Once the application is created, change the directory to hello-world and launch the application wiht the following command:

cd hello-world
ng serve

You should see the following output:

** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **


? Compiled successfully.
? Browser application bundle generation complete.

Initial Chunk Files | Names  |      Size
styles.css          | styles | 119 bytes

4 unchanged chunks

Build at: 2021-04-07T05:56:55.420Z - Hash: 7af40beb75c73ecdc1c9 - Time: 523ms

? Compiled successfully.

As you can see, your application is started and listening on port 4200 on the locahost.

Press CTRL+C to stop the application.

If you want to launch your application on a specific IP address or port, run the following command:

ng serve --host 0.0.0.0 --port 3000

You should get the following output:

Initial Chunk Files | Names         |      Size
vendor.js           | vendor        |   2.69 MB
polyfills.js        | polyfills     | 128.74 kB
main.js             | main          |  56.94 kB
runtime.js          | runtime       |   6.15 kB
styles.css          | styles        | 119 bytes

                    | Initial Total |   2.87 MB

Build at: 2021-04-07T05:58:19.494Z - Hash: d50a7bd2c684713d3b6b - Time: 11348ms

** Angular Live Development Server is listening on 0.0.0.0:3000, open your browser on http://localhost:3000/ **

? Compiled successfully.

Access Angular Application

At this point, your Angular application is started and listening on port 3000 on all network interfaces. You can now access it using the URL http://your-server-ip:3000. You should see your application in the following page:

Angular app

Conclusion

Congratulations! you have successfully installed Angular on CentOS 8. You can now start building your first application with Angular and deploy it on the production environment.

Share this page:

0 Comment(s)