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 new PROJECT-NAME cd PROJECT-NAME 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 0.0.0.0 --port 4201
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 −
The table below lists some important commands required while working with Angular 7 projects –
|Sr. No||Commands and Description|
ng g component new-component
ng g directive new-directive
ng g pipe new-pipe
ng g service new-service
ng g module my-module
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.