Using Angular CLI to quickly bootstrap Angular applications

The Angular CLI makes it easy to create an application that already works, right out of the box. It already follows our best practices!

Angular CLI stands for Angular Command Line Interface. As the name implies, it is a command line tool for creating angular apps. It is recommended to use angular cli for creating angular apps as you don't need to spend time installing and configuring all the required dependencies and wiring everything together.

Installing the Angular CLI

Make sure you have latest node.js including NPM(node package manager). This package manager is responsible for automatically installing required packages, like angular cli, and all required dependencies.

npm install -g @angular/cli

This installs the CLI globally, so you can use it from any folder.

What can it do for me?

One option would be to use the ng help feature to discover all features the CLI can offer. "ng v" for example will display the current angular CLI version

Scaffolding a new angular app with ng new

ng new [name] creates a new angular application. Default applications are created in a directory of the same name, with an initialized Angular application.

Starting server with ng serve

ng serve builds the application and starts a web server.

Generate files with ng generate

ng generate is useful when we want to generate files from blueprint, ng g --help shows a list of options it can generate.

Running unit tests with ng test

ng test starts a browser and performs unit tests from project using Karma.
ng e2e runs end to ent tests using Protractor.

Building the application with ng build

ng build -prod compiles the application optimized for productions and puts them in the dist folder, or another output directory

angular angular CLI


pinte dan
About the Author

Dani Pinte

Dani is a software developer with over 10 years experience in developing Desktop and Web applications using Microsoft .NET Technologies. He is passionate about software, sports, travel and motorsport.