> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/angular/angular/llms.txt
> Use this file to discover all available pages before exploring further.

# Angular CLI Commands

> Complete reference for all Angular CLI commands with examples and options

## Command Overview

Angular CLI provides a comprehensive set of commands for every stage of development. All commands follow the pattern:

```bash theme={null}
ng <command> [options]
```

<Info>
  Use `ng <command> --help` to see detailed options for any command.
</Info>

## Essential Commands

### ng new

Create a new Angular workspace and application.

```bash theme={null}
ng new <project-name> [options]
```

<Accordion title="Options">
  <ParamField path="--routing" type="boolean" default="false">
    Generate a routing module for the application
  </ParamField>

  <ParamField path="--style" type="string" default="css">
    Stylesheet format: `css`, `scss`, `sass`, `less`, or `stylus`
  </ParamField>

  <ParamField path="--ssr" type="boolean" default="false">
    Enable Server-Side Rendering (SSR) support
  </ParamField>

  <ParamField path="--skip-git" type="boolean" default="false">
    Skip initializing a git repository
  </ParamField>

  <ParamField path="--skip-install" type="boolean" default="false">
    Skip installing npm packages
  </ParamField>

  <ParamField path="--package-manager" type="string">
    Package manager to use: `npm`, `yarn`, `pnpm`, or `cnpm`
  </ParamField>

  <ParamField path="--create-application" type="boolean" default="true">
    Create a new application in the workspace
  </ParamField>
</Accordion>

#### Examples

<CodeGroup>
  ```bash Basic theme={null}
  ng new my-app
  ```

  ```bash With Routing and SCSS theme={null}
  ng new my-app --routing --style=scss
  ```

  ```bash With SSR theme={null}
  ng new my-app --ssr
  ```

  ```bash Empty Workspace theme={null}
  ng new my-workspace --create-application=false
  ```
</CodeGroup>

***

### ng serve

Start a development server with live reload.

```bash theme={null}
ng serve [options]
```

<Accordion title="Options">
  <ParamField path="--port" type="number" default="4200">
    Port to listen on
  </ParamField>

  <ParamField path="--host" type="string" default="localhost">
    Host to listen on
  </ParamField>

  <ParamField path="--open" type="boolean" default="false">
    Automatically open browser (shorthand: `-o`)
  </ParamField>

  <ParamField path="--configuration" type="string">
    Build configuration to use (shorthand: `-c`)
  </ParamField>

  <ParamField path="--ssl" type="boolean" default="false">
    Serve using HTTPS
  </ParamField>

  <ParamField path="--proxy-config" type="string">
    Path to proxy configuration file
  </ParamField>
</Accordion>

#### Examples

<CodeGroup>
  ```bash Basic theme={null}
  ng serve
  ```

  ```bash Custom Port theme={null}
  ng serve --port 3000
  ```

  ```bash Open Browser theme={null}
  ng serve --open
  ```

  ```bash Production Configuration theme={null}
  ng serve --configuration=production
  ```

  ```bash With Proxy theme={null}
  ng serve --proxy-config proxy.conf.json
  ```
</CodeGroup>

<Tip>
  The development server is available at `http://localhost:4200` by default.
</Tip>

***

### ng build

Build the application for deployment.

```bash theme={null}
ng build [options]
```

<Accordion title="Options">
  <ParamField path="--configuration" type="string">
    Build configuration (e.g., `production`, `development`)
  </ParamField>

  <ParamField path="--output-path" type="string">
    Output directory for build artifacts
  </ParamField>

  <ParamField path="--optimization" type="boolean">
    Enable optimization of the build output
  </ParamField>

  <ParamField path="--source-map" type="boolean">
    Generate source maps
  </ParamField>

  <ParamField path="--aot" type="boolean" default="true">
    Ahead-of-Time compilation
  </ParamField>

  <ParamField path="--progress" type="boolean" default="true">
    Show build progress
  </ParamField>

  <ParamField path="--watch" type="boolean" default="false">
    Run build when files change
  </ParamField>
</Accordion>

#### Examples

<CodeGroup>
  ```bash Development Build theme={null}
  ng build
  ```

  ```bash Production Build theme={null}
  ng build --configuration=production
  ```

  ```bash Watch Mode theme={null}
  ng build --watch
  ```

  ```bash Custom Output theme={null}
  ng build --output-path=custom-dist
  ```
</CodeGroup>

#### Build Output

Production builds include:

* **AOT Compilation**: Templates compiled ahead-of-time
* **Tree Shaking**: Unused code removed
* **Minification**: Code size reduced
* **Bundle Optimization**: Efficient chunking

<Note>
  Default output directory is `dist/` (configurable in angular.json)
</Note>

***

### ng generate

Generate Angular artifacts using schematics.

```bash theme={null}
ng generate <schematic> <name> [options]
ng g <schematic> <name> [options]  # shorthand
```

#### Available Schematics

<Tabs>
  <Tab title="Component">
    ```bash theme={null}
    ng generate component <name>
    ```

    Options:

    * `--standalone`: Create standalone component (default in v17+)
    * `--skip-tests`: Skip test file generation
    * `--inline-template`: Use inline template
    * `--inline-style`: Use inline styles
    * `--flat`: Don't create a folder
    * `--export`: Export from parent module

    Example:

    ```bash theme={null}
    ng g component user-profile --standalone
    ```
  </Tab>

  <Tab title="Service">
    ```bash theme={null}
    ng generate service <name>
    ```

    Options:

    * `--skip-tests`: Skip test file generation
    * `--flat`: Don't create a folder

    Example:

    ```bash theme={null}
    ng g service auth --skip-tests
    ```
  </Tab>

  <Tab title="Module">
    ```bash theme={null}
    ng generate module <name>
    ```

    Options:

    * `--routing`: Add routing module
    * `--flat`: Don't create a folder
    * `--module`: Parent module to import into

    Example:

    ```bash theme={null}
    ng g module admin --routing
    ```
  </Tab>

  <Tab title="Directive">
    ```bash theme={null}
    ng generate directive <name>
    ```

    Options:

    * `--standalone`: Create standalone directive
    * `--skip-tests`: Skip test file generation
    * `--flat`: Don't create a folder

    Example:

    ```bash theme={null}
    ng g directive highlight --standalone
    ```
  </Tab>

  <Tab title="Pipe">
    ```bash theme={null}
    ng generate pipe <name>
    ```

    Options:

    * `--standalone`: Create standalone pipe
    * `--skip-tests`: Skip test file generation
    * `--flat`: Don't create a folder

    Example:

    ```bash theme={null}
    ng g pipe currency-format --standalone
    ```
  </Tab>

  <Tab title="Guard">
    ```bash theme={null}
    ng generate guard <name>
    ```

    Options:

    * `--functional`: Generate functional guard (default in v15+)
    * `--skip-tests`: Skip test file generation

    Example:

    ```bash theme={null}
    ng g guard auth
    ```
  </Tab>

  <Tab title="Interface">
    ```bash theme={null}
    ng generate interface <name>
    ```

    Example:

    ```bash theme={null}
    ng g interface user
    ```
  </Tab>

  <Tab title="Class">
    ```bash theme={null}
    ng generate class <name>
    ```

    Options:

    * `--type`: Type suffix (e.g., `model`, `util`)
    * `--skip-tests`: Skip test file generation

    Example:

    ```bash theme={null}
    ng g class user --type=model
    ```
  </Tab>
</Tabs>

<Tip>
  For standalone components, directives, and pipes, use the `--standalone` flag or set it as default in angular.json.
</Tip>

***

### ng test

Run unit tests using Karma and Jasmine.

```bash theme={null}
ng test [options]
```

<Accordion title="Options">
  <ParamField path="--watch" type="boolean" default="true">
    Watch files for changes and re-run tests
  </ParamField>

  <ParamField path="--code-coverage" type="boolean" default="false">
    Generate code coverage report
  </ParamField>

  <ParamField path="--browsers" type="string">
    Browsers to run tests in (e.g., `Chrome`, `Firefox`)
  </ParamField>

  <ParamField path="--include" type="string">
    Glob pattern for test files to include
  </ParamField>
</Accordion>

#### Examples

<CodeGroup>
  ```bash Watch Mode theme={null}
  ng test
  ```

  ```bash Single Run theme={null}
  ng test --watch=false
  ```

  ```bash With Coverage theme={null}
  ng test --code-coverage
  ```

  ```bash Specific Browser theme={null}
  ng test --browsers=ChromeHeadless
  ```
</CodeGroup>

<Note>
  The Angular team uses Karma 6.4.0 and Jasmine 6.1.0 for testing.
</Note>

***

### ng e2e

Run end-to-end tests (requires e2e test setup).

```bash theme={null}
ng e2e [options]
```

<Warning>
  Starting with Angular v12, e2e testing is not included by default. You need to add a third-party e2e testing tool like Cypress or Playwright.
</Warning>

***

### ng lint

Run linting tools on Angular app code.

```bash theme={null}
ng lint [options]
```

<Note>
  Requires ESLint or TSLint configuration. The Angular team uses TSLint 6.1.3 in the source repository.
</Note>

***

### ng update

Update Angular packages and dependencies.

```bash theme={null}
ng update [packages]
```

#### Examples

<CodeGroup>
  ```bash Check for Updates theme={null}
  ng update
  ```

  ```bash Update Angular Core theme={null}
  ng update @angular/core @angular/cli
  ```

  ```bash Update All theme={null}
  ng update @angular/core @angular/cli --force
  ```
</CodeGroup>

<Accordion title="Update Options">
  <ParamField path="--force" type="boolean">
    Force update even if there are peer dependency warnings
  </ParamField>

  <ParamField path="--migrate-only" type="boolean">
    Only run migrations, don't update packages
  </ParamField>

  <ParamField path="--from" type="string">
    Version to migrate from
  </ParamField>

  <ParamField path="--to" type="string">
    Version to migrate to
  </ParamField>
</Accordion>

***

### ng add

Add external libraries to your project with automatic configuration.

```bash theme={null}
ng add <package>
```

#### Popular Packages

<CodeGroup>
  ```bash Angular Material theme={null}
  ng add @angular/material
  ```

  ```bash Angular PWA theme={null}
  ng add @angular/pwa
  ```

  ```bash Angular Localize theme={null}
  ng add @angular/localize
  ```

  ```bash Angular SSR theme={null}
  ng add @angular/ssr
  ```
</CodeGroup>

<Info>
  The `ng add` command automatically installs packages and runs configuration schematics.
</Info>

***

### ng version

Display Angular CLI and package versions.

```bash theme={null}
ng version
ng v  # shorthand
```

Outputs:

* Angular CLI version
* Node.js version
* Package manager version
* TypeScript version
* Angular package versions

***

### ng config

Get or set Angular configuration values.

```bash theme={null}
ng config <key> [value]
```

#### Examples

<CodeGroup>
  ```bash Get Value theme={null}
  ng config cli.analytics
  ```

  ```bash Set Value theme={null}
  ng config cli.analytics false
  ```

  ```bash Get Package Manager theme={null}
  ng config cli.packageManager
  ```

  ```bash Set Package Manager theme={null}
  ng config cli.packageManager pnpm
  ```
</CodeGroup>

***

### ng analytics

Manage Angular CLI analytics settings.

```bash theme={null}
ng analytics <command>
```

<Tabs>
  <Tab title="Enable">
    ```bash theme={null}
    ng analytics on
    ```
  </Tab>

  <Tab title="Disable">
    ```bash theme={null}
    ng analytics off
    ```
  </Tab>

  <Tab title="Info">
    ```bash theme={null}
    ng analytics info
    ```
  </Tab>

  <Tab title="Prompt">
    ```bash theme={null}
    ng analytics prompt
    ```
  </Tab>
</Tabs>

***

### ng extract-i18n

Extract internationalization messages from templates.

```bash theme={null}
ng extract-i18n [options]
```

<Accordion title="Options">
  <ParamField path="--format" type="string" default="xlf">
    Output format: `xlf`, `xlf2`, `xmb`, `json`, `arb`
  </ParamField>

  <ParamField path="--output-path" type="string">
    Output directory for translation files
  </ParamField>

  <ParamField path="--out-file" type="string">
    Output file name
  </ParamField>
</Accordion>

#### Example

```bash theme={null}
ng extract-i18n --format=xlf2 --output-path=src/locale
```

***

## Migration Commands

Angular provides several migration schematics:

<Tabs>
  <Tab title="Standalone Migration">
    Convert to standalone components:

    ```bash theme={null}
    ng generate @angular/core:standalone
    ```

    Options:

    * Convert declarations to standalone
    * Remove unnecessary NgModules
    * Switch to standalone bootstrapping
  </Tab>

  <Tab title="Control Flow Migration">
    Migrate to new control flow syntax:

    ```bash theme={null}
    ng generate @angular/core:control-flow-migration
    ```

    Converts `*ngIf`, `*ngFor`, `*ngSwitch` to `@if`, `@for`, `@switch`
  </Tab>

  <Tab title="Signal Inputs">
    Migrate to signal inputs:

    ```bash theme={null}
    ng generate @angular/core:signal-input-migration
    ```
  </Tab>

  <Tab title="Signal Queries">
    Migrate to signal queries:

    ```bash theme={null}
    ng generate @angular/core:signal-queries-migration
    ```
  </Tab>
</Tabs>

***

## Command Aliases

<ResponseField name="Common Shortcuts">
  | Full Command                          | Alias                | Description            |
  | ------------------------------------- | -------------------- | ---------------------- |
  | `ng generate`                         | `ng g`               | Generate schematics    |
  | `ng serve --open`                     | `ng s -o`            | Serve and open browser |
  | `ng build --configuration=production` | `ng b -c production` | Production build       |
  | `ng test`                             | `ng t`               | Run tests              |
  | `ng version`                          | `ng v`               | Show version           |
</ResponseField>

***

## Global Flags

These flags work with any command:

<ParamField path="--help" type="boolean">
  Show help information (shorthand: `-h`)
</ParamField>

<ParamField path="--dry-run" type="boolean">
  Run command without making changes (shorthand: `-d`)
</ParamField>

<ParamField path="--force" type="boolean">
  Force overwriting of files (shorthand: `-f`)
</ParamField>

<ParamField path="--skip-import" type="boolean">
  Skip importing into NgModule
</ParamField>

<ParamField path="--project" type="string">
  Target project in multi-project workspace
</ParamField>

***

## Next Steps

<CardGroup cols={2}>
  <Card title="Builders" icon="hammer" href="/cli/builders">
    Learn about custom build processes
  </Card>

  <Card title="Schematics" icon="wand-magic-sparkles" href="/cli/schematics">
    Create custom code generators
  </Card>
</CardGroup>
