Using angular cli commands you can easily scaffold and build the angular application. Here I list and discuss the commands available in angular cli. As you know Angular development approach changes and the architecture got numerous improvements after the latest release. Along with that the angular/cli also upgrade to support the modern angular javascript framework.
angular/cli
angular/cli is a tool that helps you to start, build and test you angular application easily. angular/cli uses several commands to initialize, scaffold and maintain the application. Let’s see the most commonly used commands while creating the angular application. Before starting you need to install the angular/cli package.
Note:npm uninstall -g angular-cli @angular/cli && npm cache clean && npm install –save-dev @angular/cli@latest
Consolidated list of angular cli commands
angular/cli action | Command | Shortened |
New Application | ng new app-name | ng new app-name |
Create Component | ng generate component component-name | ng g c component-name |
Create Directive | ng generate directive directive-name | ng g d directive-name |
Create Pipe | ng generate pipe pipe-name | ng g p pipe-name |
Create Service | ng generate service service-name | ng g s service-name |
Create Class | ng generate class class-name | ng g cl class-name |
Create Guard | ng generate guard guard-name | ng g g guard-name |
Create Interface | ng generate interface interface-name | ng g i interface-name |
Create Enum | ng generate enum enum-name | ng g e enum-name |
Create Module | ng generate module module-name | ng g m module-name |
Lint using tslint | ng lint | ng lint |
Build & run unit test | ng test | ng test |
Run end to end test | ng e2e | ng e2e |
Compile application to output Dir | ng build (–dev/–prod) | ng build (–dev/–prod) |
Eject app and create proper webpack configuration and script bundle | ng eject | ng eject |
Extract localization i18n message from template | ng xi18n | ng xi18n |
Build and start web server | ng serve | ng serve |
The above mentioned are the basic angular/cli commands. You can also use options as a parameter along with the commands to narrow down the required behavior of cli.
VERY HELPFUL!