The Angular CLI provides 16 primary commands covering the entire Angular development lifecycle, from project creation through deployment. Each command supports extensive configuration options and can be used both interactively and in automated environments.
Commands for creating new projects and managing existing workspaces.
Create a new Angular workspace and application.
ng new <name> [options]
ng n <name> [options] # aliasCommon Options:
--routing: Add routing module--style=<format>: Stylesheet format (css, scss, sass, less)--skip-git: Skip git repository initialization--skip-install: Skip package installation--package-manager=<manager>: Package manager to useUsage Examples:
# Create basic Angular application
ng new my-app
# Create with routing and SCSS
ng new my-app --routing --style=scss
# Create without git and package installation
ng new my-app --skip-git --skip-install
# Create with specific package manager
ng new my-app --package-manager=pnpmAdd packages to an Angular workspace with automatic configuration.
ng add <package> [options]Usage Examples:
# Add Angular Material
ng add @angular/material
# Add PWA support
ng add @angular/pwa
# Add Angular Universal (SSR)
ng add @angular/ssrUpdate Angular packages and dependencies to newer versions.
ng update [packages...] [options]Common Options:
--all: Update all packages--force: Force update even with peer dependency warnings--migrate-only: Run migrations without updating packagesUsage Examples:
# Check for updates
ng update
# Update Angular core packages
ng update @angular/core @angular/cli
# Update all packages
ng update --allCommands for generating Angular code using schematics.
Generate code using Angular schematics.
ng generate <schematic> [options]
ng g <schematic> [options] # aliasAvailable Schematics:
component (alias: c): Generate componentservice (alias: s): Generate servicemodule (alias: m): Generate moduledirective (alias: d): Generate directivepipe (alias: p): Generate pipeguard: Generate route guardinterface (alias: i): Generate interfaceenum (alias: e): Generate enumclass (alias: cl): Generate classUsage Examples:
# Generate component
ng generate component user-profile
ng g c user-profile --skip-tests
# Generate service
ng generate service user
ng g s user --skip-tests
# Generate module with routing
ng generate module feature --routing
# Generate directive
ng generate directive highlight
ng g d highlight
# Generate pipe
ng generate pipe capitalize
ng g p capitalizeCommands for developing, building, and testing Angular applications.
Serve the application in development mode with live reload.
ng serve [options]
ng s [options] # alias
ng dev [options] # aliasCommon Options:
--port=<number>: Port to listen on--host=<host>: Host to bind to--open (alias: -o): Open browser automatically--configuration=<config>: Build configuration--prod: Use production configuration--ssl: Serve using HTTPSUsage Examples:
# Basic development server
ng serve
# Serve on specific port with browser open
ng serve --port 4300 --open
# Serve with production configuration
ng serve --configuration production
# Serve with HTTPS
ng serve --sslBuild the application for production deployment.
ng build [options]
ng b [options] # aliasCommon Options:
--configuration=<config>: Build configuration--prod: Use production configuration--output-path=<path>: Output directory--base-href=<href>: Base href for the application--source-map: Generate source mapsUsage Examples:
# Production build
ng build --configuration production
# Build with custom output path
ng build --output-path dist/my-app
# Build with source maps
ng build --source-map
# Build with custom base href
ng build --base-href /my-app/Run unit tests using the configured test runner.
ng test [options]
ng t [options] # aliasCommon Options:
--watch: Watch files for changes--code-coverage: Generate code coverage report--browsers=<browsers>: Browsers to run tests in--karma-config=<config>: Karma configuration fileUsage Examples:
# Run tests in watch mode
ng test
# Run tests once with coverage
ng test --watch=false --code-coverage
# Run tests in headless browser
ng test --browsers ChromeHeadlessRun end-to-end tests.
ng e2e [options]
ng e [options] # aliasUsage Examples:
# Run e2e tests
ng e2e
# Run e2e tests for specific project
ng e2e my-app-e2eRun linting tools on the project.
ng lint [options]Usage Examples:
# Lint all files
ng lint
# Lint with fix option
ng lint --fix
# Lint specific project
ng lint my-librarySupport commands for configuration, analytics, and tooling.
Display version information for Angular CLI and installed packages.
ng version [options]
ng v [options] # aliasUsage Examples:
# Show version information
ng version
# Show abbreviated version
ng vGet and set Angular CLI configuration values.
ng config [json-path] [value] [options]Usage Examples:
# Show all configuration
ng config
# Get specific configuration value
ng config cli.packageManager
# Set configuration value
ng config cli.packageManager pnpm
# Set global configuration
ng config --global cli.packageManager yarnConfigure Angular CLI usage analytics.
ng analytics <setting> [options]Settings:
on: Enable analyticsoff: Disable analyticsinfo: Show analytics statusprompt: Show analytics promptUsage Examples:
# Enable analytics
ng analytics on
# Disable analytics
ng analytics off
# Check analytics status
ng analytics infoSet up command-line autocompletion for the Angular CLI.
ng completion [options]Usage Examples:
# Set up bash completion
ng completion
# Generate completion script
ng completion scriptSpecialized commands for advanced use cases.
Manage the Angular CLI build cache.
ng cache [options]Subcommands:
clean: Clean the cachedisable: Disable cachingenable: Enable cachinginfo: Show cache informationUsage Examples:
# Clean build cache
ng cache clean
# Show cache info
ng cache info
# Disable cache
ng cache disableDeploy the application using configured deployment builders.
ng deploy [options]Usage Examples:
# Deploy using default configuration
ng deploy
# Deploy with specific configuration
ng deploy --configuration productionExtract internationalization messages from the application.
ng extract-i18n [options]Common Options:
--output-path=<path>: Output directory for extracted messages--format=<format>: Output format (xlf, xlf2, xliff, xliff2, json)Usage Examples:
# Extract i18n messages
ng extract-i18n
# Extract with custom output path
ng extract-i18n --output-path locale
# Extract in JSON format
ng extract-i18n --format jsonExecute custom architect targets defined in angular.json.
ng run <target> [options]Usage Examples:
# Run custom build target
ng run my-app:build:production
# Run custom lint configuration
ng run my-app:lint:strictStart Model Context Protocol server for AI integration.
ng mcp [options]Usage Examples:
# Start MCP server
ng mcp
# Start MCP server on specific port
ng mcp --port 3000Hidden motivational command that displays encouraging messages for developers.
ng make-this-awesomeUsage Examples:
# Display motivational message
ng make-this-awesomeNote: This is a hidden easter egg command that provides motivational phrases to developers. It performs no actual operations but can boost morale during development sessions.
All commands support common global options:
--help: Show help information--version: Show version information--verbose: Enable verbose logging--quiet: Suppress non-error outputCommands return standard exit codes:
0: Success1: General error2: Invalid usage3: Environment error (Node.js version)Commands recognize these environment variables:
NG_DEBUG: Enable debug loggingNG_DISABLE_VERSION_CHECK: Skip version compatibility checksNG_CLI_ANALYTICS: Override analytics settingNG_FORCE_TTY: Force TTY mode