View video tutorial
ANGULAR CLI Commands
ANGULAR
This tutorial lists some important Angular CLI commands.
CLI Commands Example
- Command syntax is: ng [command] [options]
- Most commands, and some options, have aliases. The alias for options must be preceded by a single dash (-) character.
- The option name must be preceded by two double dash (--) characters but the alias for options must be preceded by a single dash (-) character. Commands are not prefixed.
- Most commands are used with the schematic command like
ng [commnad schematic]. Example:ng generate component user. Here component is the schematic name.
ng help
ng generate --help
ng generate component user --inline-style --inline-template
ng g c user -s -t
To create project
ng new my-first-project
cd my-first-project
ng serve
To create component
ng generate component componentName
ng g c componentName
To create class
ng generate class className
ng g cl className
To create service
ng generate service serviceName
ng g s serviceName
Basic CLI Commands
| Command | Alias | Description |
|---|---|---|
| add | This command adds support for an external library to the project. | |
| analytics | This command configures the collection of Angular CLI usage metrics. | |
| build | b | This command compiles an Angular application or library into an output directory named dist/ at the given output path. |
| cache | It configures persistent disk cache and retrieves cache statistics. | |
| completion | This sets up Angular CLI autocompletion for the terminal. | |
| config | It retrieves or sets the Angular configuration values in the angular.json file.. | |
| deploy | This invokes the builder to a specific project or to the default project in the workspace. | |
| doc | This opens the Angular documentation in a browser. | |
| e2e | It builds, serves, and then runs end-to-end tests. | |
| extract-i18n | It extracts the i18n message from the source code. | |
| generate | g | This command creates and/or modifies files based on the keywords or topics used. |
| lint | It runs linting tools on Angular application code. | |
| new | n | This command creates a new Angular project. |
| run | It runs a target Angular project. | |
| serve | s | This command builds and serves the application. |
| test | t | This command is used to run the unit tests on a project. |
| update | Updates the project and its dependencies. | |
| version | v | This shows the Angular CLI version. |