Home >>Angular7 Tutorial >Angular7 CLI Prompts

Angular7 CLI Prompts

Angular7 CLI Prompts

Angular CLI makes any Angular Project easy to start. Angular CLI comes with commands that help us create and get started very fast on our project. Now let's go through the available commands to create a project, a component, and services, change the port, etc.

We need to get it built on our system to installed with Angular CLI. Let us use the command below for the same –

npm install -g @angular/cli

We can run the following command in the command line to build a new project, and it will create the project.

ng serve //
ng serve // will compile and you can see the output of your project in the browser −

4200 is the default port to use when creating a new project. The following command can change the port-

ng serve --host --port 4201

Command for Angular Update

If you want your application and its dependencies updated, you can use the following command –s

ng update @angular/cli @angular/core

The new version, i.e. Angular 7 and also angular-cli, will be updated to core framework. The above command can be used with the following options −

Angular Important Command List

The table below lists some important commands required while working with Angular 7 projects –

Sr. No Commands and Description
1 Component
ng g component new-component
2 Directive
ng g directive new-directive
3 Pipe
ng g pipe new-pipe
4 Service
ng g service new-service
5 Module
ng g module my-module
6 Test
ng test
7 Build
ng build --configuration=production // for production environment
ng build --configuration=staging // for stating environment

Every time a new module, component, or service is created, the parent module app.module.ts updates the reference for the same.