• Skip to main content
  • Skip to primary sidebar
  • Skip to footer
  • Home
  • AI
  • Javascript
  • TypeScript
  • Development
  • Frameworks
    • Angular
    • Git
    • NestJs

The code Mood

Ignite Passion, Master Code

You are here: Home / Frameworks / Angular / Angular CLI Commands: 15 Powerful Shortcuts Every Developer Must Know (2025 Guide)

Angular CLI Commands: 15 Powerful Shortcuts Every Developer Must Know (2025 Guide)

by Ahmed Fakhar Abbas

If you’ve ever built an Angular app manually, you know the struggle: endless setup, file wiring, and repetitive boilerplate. That’s where Angular CLI Commands step in. They automate the heavy lifting — creating projects, generating components, testing, and even deployment — so you can focus on building features instead of wrestling with configs.

In this guide, we’ll explore 15 essential Angular CLI Commands that every developer should know in 2025. Whether you’re just starting with Angular or upgrading to Angular 17, these commands will save you time, reduce errors, and keep your workflow consistent.

Angular CLI Commands vs Manual Setup – A Side-by-Side Comparison
Angular CLI Commands vs Manual Setup – A Side-by-Side Comparison

Here’s how I use them — no fluff, just the stuff that works

Table of Contents

Toggle
  • Installing Angular CLI
  • Creating Your First Angular Project
  • What’s Inside the Project?
  • Understanding the Project Structure
  • The Angular CLI Command Format
  • Generate Components, Services, and More
  • Running and Serving Your App
  • Building for Production
  • Adding Dependencies with ng add
  • Keeping Your Project Updated with ng update
  • Running Tests with ng test
  • Linting Code with ng lint
  • Exploring ng e2e for End-to-End Testing
  • Using ng generate for Advanced Scaffolding
  • Deploying Apps with Angular CLI
  • The 7 Commands I Use All the Time
  • Bonus Pro Tips to Master Angular CLI
  • FAQs on Angular CLI Commands:

Installing Angular CLI

To start using Angular CLI anywhere on your system, install it globally:

npm install -g @angular/cli

Verify the installation with:

ng version


💡 Pro Tip: Keep it updated! Angular CLI releases new features regularly. Check the Angular CLI GitHub releases page or simply run:
ng update @angular/cli @angular/core

Creating Your First Angular Project

Spinning up a brand-new Angular app is as easy as:

ng new task-tracker
cd task-tracker
ng serve

Visit http://localhost:4200 and boom — your app is running with live reload enabled.

No manual builds, no browser refreshes. Just write, save, and see changes instantly.

What’s Inside the Project?

Running ng new builds out a full workspace:

  • src/ – your actual app
  • projects/ – optional, if you’re juggling multiple apps/libs
  • angular.json – config central; controls build and serve behavior

You don’t have to touch angular.json often, but it’s good to know where the knobs and switches live.

Understanding the Project Structure

When you generate a project with ng new, Angular CLI builds a standard workspace:

  • src/ – main application code
  • projects/ – for multiple apps or libraries
  • angular.json – your configuration hub
  • package.json – dependency manager
  • tsconfig.json – TypeScript configuration

This structure ensures consistency across Angular projects — whether it’s your first app or your fiftieth.For modern reactivity approaches, check out Angular Signals: 9 Powerful Reasons They’re Revolutionizing Reactive Programming.

The Angular CLI Command Format

Most Angular CLI Commands follow a consistent pattern:

ng [command] [name] --[options]

Examples:

ng g c dashboard --skip-tests
ng build --configuration production

Options can be:

  • Short (-t)
  • Long (--skip-tests)
  • Boolean flags (--enable-xyz or --no-enable-xyz)

Knowing this format makes commands easier to remember (and saves you from constant Googling).

Generate Components, Services, and More

One of the most powerful Angular CLI features is scaffolding:

ng generate component login-form
# shorthand
ng g c login-form

Other useful generators:

ng g service auth
ng g guard auth
ng g directive highlight
ng g pipe capitalize

💡 Pro Tip: Add --flat to avoid creating a new folder, or --module app to auto-import in a specific module.

Running and Serving Your App

To run your project locally:

ng serve
# or shorthand
ng s

By default, it runs on port 4200, but you can change it:

ng serve --port 4500

Now you can run multiple Angular apps simultaneously without conflicts.

Building for Production

Ready to ship your app? Run:

ng build --configuration production

This optimizes your code by minifying, tree-shaking, and bundling assets. The output lives inside the dist/ folder, ready to be deployed.

💡 Pro Tip: Use custom configurations in angular.json for staging or testing environments.

Adding Dependencies with ng add

Instead of manually editing configs, let CLI handle it:

ng add @angular/material

This installs Angular Material and updates your project automatically. No more fiddling with package.json or angular.json.

Keeping Your Project Updated with ng update

Stay current with Angular’s ecosystem:

ng update

It suggests updates and even applies migrations. This keeps your project secure, optimized, and aligned with Angular’s best practices.

Running Tests with ng test

Unit tests are first-class citizens in Angular:

ng test
# shorthand
ng t

This launches Karma, runs your tests, and gives real-time feedback.

Linting Code with ng lint

Catch bugs before they reach production:

ng lint

It runs your linting configuration (usually ESLint) and ensures your code follows best practices.

Exploring ng e2e for End-to-End Testing

For full workflow tests:

ng e2e

This runs your app in a browser and tests real user scenarios using Protractor or Cypress (depending on setup).

Using ng generate for Advanced Scaffolding

ng generate goes beyond components and services. You can scaffold:

  • Modules: ng g module feature
  • Routing: ng g module app-routing --flat --module=app
  • Interfaces: ng g interface user

This keeps your project structure clean and consistent.

Deploying Apps with Angular CLI

Deployment is easier than ever:

ng deploy

This command integrates with platforms like Firebase Hosting, Netlify, and GitHub Pages — no manual setup required.

The 7 Commands I Use All the Time

While Angular CLI has dozens of commands, these 7 Angular CLI Commands are burned into my muscle memory because I use them almost daily:

CommandDescription
ng addCreates a new Angular project
ng buildCompiles your app for production (alias: ng b).
ng serveServes your app locally and watches for file changes (alias: ng s).
ng lintChecks your code for issues using linting tools.
ng generateScaffolds new components, services, routes, and more (alias: ng g).
ng testRuns unit tests (alias: ng t).
ng updateUpdates Angular CLI and project dependencies

💡 Pro Tip: If you’re new to Angular CLI Commands, start with these seven. They cover 90% of common tasks, and once they’re second nature, you’ll feel a huge boost in speed and confidence.

Bonus Pro Tips to Master Angular CLI

  • Use ng help to list all available commands.
  • Alias frequently used commands (ng s -o opens the app in a browser automatically.
  • Combine flags for maximum efficiency (ng build --prod --aot).
  • Automate repetitive tasks with custom schematics.

To sum it up, the Angular CLI Commands aren’t just shortcuts — they’re the backbone of modern Angular development. From spinning up projects in seconds to deploying apps with a single command, the CLI is designed to maximize productivity and maintain consistency.

If you’ve been doing things manually, now’s the time to switch. And for cleaner Angular code, pair these with smart practices like the Async Pipe in Angular.

And there you have it — 15 Angular CLI Commands every developer should master in 2025, plus my personal 7 go-to favorites. Start with the basics, build confidence, and then explore the advanced commands as you grow.

Happy coding, and may the CLI always be on your side! ⚡

FAQs on Angular CLI Commands:

Angular CLI Commands are built-in shortcuts provided by the Angular Command Line Interface (CLI) that automate common development tasks. Instead of manually creating files or configuring builds, you can use commands like ng generate, ng serve, and ng build to speed up your workflow.

You can update Angular CLI and project dependencies with:

ng update @angular/cli @angular/core

This keeps your project up to date with the latest Angular features and security patches.

You can install Angular CLI globally using npm:

npm install -g @angular/cli

Once installed, check the version with:

ng version

This ensures you have the latest CLI ready to use.

Using Angular CLI Commands eliminates repetitive tasks like file creation, wiring imports, and configuring builds. It also enforces best practices, keeps your project structure consistent, and significantly boosts developer productivity.

To create a new project, use:

ng new project-name

For example:

ng new task-tracker

This generates a ready-to-use Angular app with a preconfigured structure.

Use the following command:

ng serve

By default, your app runs on http://localhost:4200. You can change the port with:

ng serve --port 4500
  • ng build compiles your Angular application into the dist/ folder, optimized for deployment.
  • ng serve runs your application locally with live reload enabled. It’s mainly used during development.

Yes! Angular CLI provides commands for both unit tests and end-to-end (E2E) tests:

ng test   # Runs unit tests
ng e2e    # Runs end-to-end tests

This makes testing seamless without extra setup.

Instead of manual installation, you can use:

ng add @angular/material

This not only installs the library but also configures your project automatically.

Technically, no — you can set up Angular apps manually with Webpack and TypeScript. But in practice, using Angular CLI Commands is the recommended way. It saves time, reduces errors, and ensures your project aligns with Angular’s official best practices.

Filed Under: Angular

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Recent Posts

  • 5 Programming Jokes That Prove Java Developers Have the Best Sense of Humor
  • Bridging the Gap: The Crucial Role of Developer Advocates in the Software Landscape
  • Long Hair and Beard: 9 Fascinating Secrets Behind Programmers’ Iconic Look
  • ServiceNow vs Salesforce: 7 Must-Know Differences to Choose the Best CRM Solution
  • Will Devin AI Take Your Job?

Categories

  • AI
  • Angular
  • Development
  • Git
  • Javascript
  • NestJs
  • TypeScript

Footer

  • About Us
  • Privacy Policy
  • Contact Us

Copyright © 2026 · The code Mood