How to install Angular CLI on CentOS 8

How to install Angular CLI on CentOS 8

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

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

prerequisites

  • 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 on your server. If it is not installed, you can install it with the following command:

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

After the installation is complete, use the following command to verify the installed version of Node.js:

node --version

Output:

v14.16.1

You can also use the following command to verify the NPM version:

npm --version

Output:

6.14.12

Install Angular/CLI

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

npm install -g @angular/cli

After the installation is complete, use the following command to verify the installed version of Angular/CLI:

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 easy way to create and deploy applications in production and local environments.

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

ng new hello-world

After creating the application, change the directory to hello-world and start the application with the following command:

cd hello-worldng 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 has started and is listening on port 4200 of locahost.

press Ctrl + C Stop the application.

If you want to start the 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 corner app

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

in conclusion

Congratulations! You have successfully installed Angular on CentOS 8. You can now start to build your first application with Angular and deploy it in a production environment.

Sidebar