How to Install Angular CLI on macOS

Channel: Linux
Abstract: Using the -g above command will install the Angular CLI tool globally. So it will be accessible to all users and applications on the system. Angular C

This tutorial will help you to install Angular.js on your macOS operating system via command line. You must need to install Homebrew package manager on your macOS.

Step 1 – Prerequsities

Let’s start the installation of Node.js on your macOS system using Homebrew. So first update the Homebrew package manager index. Then you can install Node.js package in your MacOS system using the following command:

brew update  
brew install node

You have successfully installed Node.js on your system. Execute below command on the terminal to view the installed Node.js version info.

node -v

v12.4.0
Step 2 – Install Angular/CLI on macOS

After installing the Node.js and npm on your system, use the following commands to install the Angular CLI tool on your system globally.

npm install -g @angular/cli

This command will install the latest available Angular CLI version on your macOS system. If you need any other Angular version on your macOS use one of the following commands as per required version.

npm install -g @angular/[email protected]6     #Angular 6
npm install -g @angular/[email protected]7     #Angular 7
npm install -g @angular/[email protected]8     #Angular 8
npm install -g @angular/[email protected]9     #Angular 9

Using the -g above command will install the Angular CLI tool globally. So it will be accessible to all users and applications on the system. Angular CLI provides a command ng used for command-line operations. Let’s check the installed version of ng on your system.

ng --version

Step 3 – Create New Angular Application

Now, create a new application named hello-angular4 using the Angular CLI tools. Execute the commands to do this:

ng new hello-angular4

Output:

...
...
added 1011 packages from 1041 contributors and audited 19005 packages in 55.774s
found 0 vulnerabilities

    Successfully initialized git.

This will create a directory named hello-angular4 in your current directory, and create an application.

Step 4 – Serve Angular Application

Your basic Angular application is ready to serve. Change directory to hello-angular4 and run your Angular application using ng serve command.

cd hello-angular4
ng serve

You can access your angular application on localhost port 4200, Which is the default host and port used by Angular application.

  • http://localhost:4200


You can change host and port for running Angular application by providing –host and –port command line arguments.

ng serve --host 0.0.0.0 --port 8080

The IP address 0.0.0.0 listens on all interfaces and publically accessible.

Ref From: tecadmin

Related articles