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 following commands to install Angular CLI tool on your system globally.
npm install -g @angular/cli
Using the -g above command will install the Angular CLI tool globally. So it will be accessible to all users and application 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.
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
... ... 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.
ng serve --host 0.0.0.0 --port 8080
The IP address 0.0.0.0 listens on all interfaces and publically accessible.