Installing Angular CLI

To leverage the power of the Angular CLI, begin by installing it using the npm package manager:

npm install -g @angular/cli

For information about changes between versions and updating from previous releases, refer to the Releases tab on GitHub.

Basic Workflow

Invoke the Angular CLI using the ng executable. For help on commands or options, use:

ng --help
ng new --help

To create, build, and serve a new Angular project, follow these commands:

ng new my-first-project
cd my-first-project
ng serve

Visit http://localhost:4200/ in your browser to view the new application. The ng serve command automatically rebuilds and reloads the page on source file changes.

Ensure you have sufficient rights in the current working directory or navigate to a different directory using cd <path-to-other-directory>.

Workspaces and Project Files

The ng new command generates an Angular workspace folder containing a new application skeleton. A workspace can house multiple applications and libraries. Applications and libraries are organized within the projects/ subfolder.

Each application, found in the src folder, contains the source files for a root module, a root component, and templates. Use ng generate to add components, services, pipes, directives, etc., to your project.

Workspace and Project Configuration

A single workspace configuration file, angular.json, is created at the workspace's top level. Set per-project defaults and specify configurations for different targets using this file. Use the ng config command or directly edit angular.json for configuration.

Note: Configuration file option names use camelCase, while option names for commands must be in dash-case.

CLI Command-Language Syntax

The general command syntax is:

ng [optional-arg] [options]