</>
Skip to content
Angular lessons (5/43)

Angular — CLI

Common Commands

CommandDescription
ng newCreate new project
ng serveStart dev server
ng buildBuild for production
ng generateGenerate files
ng testRun unit tests
ng e2eRun e2e tests
ng lintLint project

Generate Commands

# Components
ng generate component header
ng g c header

# Services
ng generate service services/user
ng g s services/user

# Modules
ng generate module admin
ng g m admin

# Pipes
ng generate pipe pipes/date
ng g p pipes/date

# Directives
ng generate directive directives/highlight
ng g d directives/highlight

Build Options

# Development
ng build

# Production
ng build --configuration production

# Watch mode
ng build --watch

Serve Options

# Default port
ng serve

# Custom port
ng serve --port 8080

# Open browser
ng serve --open

# SSL
ng serve --ssl

Mini Practice

  1. Generate components
  2. Generate services
  3. Build for production
  4. Configure serve options

Up Next

Continue with Project Structure — understanding the project.

Related Topics

Frequently Asked Questions about CLI

What is CLI in Angular?

CLI is a fundamental concept in Angular. This lesson explains it step by step with clear examples, making it easy for beginners to understand.

How do I learn CLI?

Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn CLI.

Why is CLI important in Angular?

CLI is essential for Angular development. Understanding this concept will help you write better code and solve real-world problems more effectively.