Welcome to the free & complete Angular Tutorial.

This lesson is all about Introduction to Angular command line interface (cli) commands.

If you are yet to install Angular CLI in your machine, please install it from their website.

As you may already know, Angular CLI (ng) is used to create new projects, build / package application, in this post we will see what are the frequently used commands in Angular app development.

Full list of Angular CLI commands is here.

Let’s begin !

ng new

Creates a new workspace and an initial Angular app.

Syntax:

ng new <project name>

ng n <project name>

ng generate

Generates and/or modifies files based on a schematic.

Syntax:

ng generate [options]
ng g [options]

Create class

ng generate class <class name>

Create Module

ng generate module <module name>

Create component

ng generate component <component name>

Create pipe

ng generate pipe <pipe name>

Create service

ng generate service <service name>

Create directive

ng generate directive <directive name>

[pgcustomfooter]

ng build

Compiles an Angular app into an output directory named dist/ at the given output path. Must be executed from within a workspace directory.

Syntax:

ng build <project> [options]

ng b <project> [options]

To build the application with production target configuration, add option –prod=true as given below:

ng build –prod=true

ng build –prod

ng serve

Builds and serves your app, rebuilding on file changes.

Syntax:

ng serve

ng s

If you want the URL to be opened in default browser:

ng serve –open

ng serve -o

ng s –open

ng s -o

ng doc

Opens the official Angular documentation (angular.io) in a browser, and searches for a given keyword.

Syntax:

ng doc [options]
ng d [options]

ng d module

ng d pipe

ng help

Lists available commands and their short descriptions.

Syntax:

ng help [options]

ng help generate

ng help serve

For detailed list of all commands, please take a look at official Angular documentation.