How to use the Angular CLI command line

Created
Modified
How to use the Angular CLI command line

The Angular CLI is a command-line interface tool that you use to initialize, develop, scaffold, and maintain Angular applications directly from a command shell.

Install the CLI using the npm package manager:

Install
npm install -g @angular/cli
ng version
Angular CLI: 11.2.14
Node: 14.17.1
OS: darwin x64

To create, build, and serve a new, basic Angular project on a development server, go to the parent directory of your new workspace use the following commands:

Create
ng new project
cd project
ng serve
? Do you want to enforce stricter type checking and stricter bundle budgets in the workspace?
  This setting helps improve maintainability and catch bugs ahead of time.
  For more information, see https://angular.io/strict Yes
? Would you like to add Angular routing? Yes
? Which stylesheet format would you like to use? SCSS   [ https://sass-lang.com/documentation/syntax#scss                ]
CREATE project/README.md (1017 bytes)
......
Compiles an Angular app into an output directory
ng build
✔ Browser application bundle generation complete.
✔ Copying assets complete.
✔ Index html generation complete.

Initial Chunk Files | Names         |      Size
vendor.js           | vendor        |   2.36 MB
polyfills.js        | polyfills     | 128.77 kB
main.js             | main          |  55.85 kB
runtime.js          | runtime       |   6.15 kB
styles.css          | styles        | 118 bytes

                    | Initial Total |   2.54 MB

Build at: 2021-06-27T12:30:22.658Z - Hash: f06216c42fb3364520f2 - Time: 10516ms

The Angular CLI Help Commands and Options



Options:
add
Adds support for an external library to your project.
analytics
Configures the gathering of Angular CLI usage metrics. See https://angular.io/cli/usage-analytics-gathering.
build (b)
Compiles an Angular app into an output directory named dist/ at the given output path. Must be executed from within a workspace directory.
deploy
Invokes the deploy builder for a specified project or for the default project in the workspace.
config
Retrieves or sets Angular configuration values in the angular.json file for the workspace.
doc (d)
Opens the official Angular documentation (angular.io) in a browser, and searches for a given keyword.
e2e (e)
Builds and serves an Angular app, then runs end-to-end tests using Protractor.
extract-i18n (i18n-extract, xi18n)
Extracts i18n messages from source code.
generate (g)
Generates and/or modifies files based on a schematic.
help
Lists available commands and their short descriptions.
lint (l)
Runs linting tools on Angular app code in a given project folder.
new (n)
Creates a new workspace and an initial Angular application.
run
Runs an Architect target with an optional custom builder configuration defined in your project.
serve (s)
Builds and serves your app, rebuilding on file changes.
test (t)
Runs unit tests in a project.
update
Updates your application and its dependencies. See https://update.angular.io/
version (v)
Outputs Angular CLI version.

Related Tags