How to install Angular and create your first app

June 1, 2019

To install Angular you first need to have installed npm.
If you want to know how to install npm on Mac OS X follow this link.


Install Angular

Once you have npm installed on your system, open a terminal window and type the following command:


npm install -g @angular/cli

The above command will download Angular files and libraries.


Create your first app

Now you are ready to create your first app.
On a terminal window type the following command:


ng new my-app

You can name the app with any name you want. On this example it has been named my-app.


You will be prompted with a couple of questions. The first question asks if you want to add Angular routing, and the second question asks which stylesheet format you would like to use. You can press Return on both questions to accept the defaults.


The above command will create a new directory, with the name of your app; and will setup a default component and template.


After the default app is created, open the app's directory, and run the "ng serve --open" command. This command will compile your app, and immediately after, launch it on your default browser.


cd my-app
ng serve —-open