Angular CLI - ng help Command



Angular CLI has a large number of built-in commands, each with various options and arguments. When developers encounter issues with specific commands, they might search online which can affect their workflow and productivity in a negative way.

Therefore, the Angular team introduced the ng --help command so that a developer can view available commands with their short descriptions directly in the terminal without an internet connection. It makes their work easier and saves time.

Syntax

If you want to list out all the available commands in Angular CLI, use the following syntax of ng --help command −

ng help [options]
Or, 
ng --help [options]

To get help with a specific command of Angular CLI, the following syntax of ng --help command is used −

ng [command] help
Or,
ng [command] --help

Options

The ng --help command has a single optional parameter, which is as follows −

Sr.No. Option & Syntax Description
1 --help= true|false|json|JSON Shows a help message for this command in the console. Default: false

Example 1

In this example, we use ng help command to display the list of commands −

\> ng help
ng

Commands:
  ng add <collection>            Adds support for an external library to your project.
  ng analytics                   Configures the gathering of Angular CLI usage metrics.
  ng build [project]             Compiles an Angular application or library into an output directory named dist/ at the given output path.      
                                                                                                                                    [aliases: b]
  ng cache                       Configure persistent disk cache and retrieve cache statistics.
  ng completion                  Set up Angular CLI autocompletion for your terminal.
  ng config [json-path] [value]  Retrieves or sets Angular configuration values in the angular.json file for the workspace.
  ng deploy [project]            Invokes the deploy builder for a specified project or for the default project in the workspace.
  ng e2e [project]               Builds and serves an Angular application, then runs end-to-end tests.                              [aliases: e]
  ng extract-i18n [project]      Extracts i18n messages from source code.
  ng generate                    Generates and/or modifies files based on a schematic.                                              [aliases: g]
  ng lint [project]              Runs linting tools on Angular application code in a given project folder.
  ng new [name]                  Creates a new Angular workspace.                                                                   [aliases: n]
  ng run <target>                Runs an Architect target with an optional custom builder configuration defined in your project.
  ng serve [project]             Builds and serves your application, rebuilding on file changes.                               [aliases: dev, s]
  ng test [project]              Runs unit tests in a project.                                                                      [aliases: t]
  ng update [packages..]         Updates your workspace and its dependencies. See https://update.angular.dev/.
  ng version                     Outputs Angular CLI version.                                                                       [aliases: v]

Options:
  --help     Shows a help message for this command in the console.                                                                     [boolean]
  --version  Show Angular CLI version.

Example 2

In case of individual commands, use the --help option with the command as shown below −

> ng serve --help
ng serve [project]

Builds and serves your application, rebuilding on file changes.

Arguments:
  project  The name of the project to build. Can be an application or a library.                                  [string] [choices: "form-app"]

Options:
      --help                Shows a help message for this command in the console.                                                      [boolean]
  -c, --configuration       One or more named builder configurations as a comma-separated list as specified in the "configurations" section in  
                            angular.json.
                            The builder uses the named configurations to run the given target.
                            For more information, see https://angular.dev/reference/configs/workspace-config#alternate-build-configurations.    
                                                                                                 [string] [choices: "development", "production"]
      --allowed-hosts       List of hosts that are allowed to access the dev server. This option has no effect when using the 'application' or  
                            other esbuild-based builders.                                                                                [array]
      --browser-target      A browser builder target to serve in the format of `project:target[:configuration]`. You can also pass in more than 
                            one configuration name as a comma-separated list. Example: `project:target:production,staging`.
                                                                                               [deprecated: Use 'buildTarget' instead.] [string]
      --build-target        A build builder target to serve in the format of `project:target[:configuration]`. You can also pass in more than   
                            one configuration name as a comma-separated list. Example: `project:target:production,staging`.             [string]
      --disable-host-check  Don't verify connected clients are part of allowed hosts. This option has no effect when using the 'application' or 
                            other esbuild-based builders.                                                             [boolean] [default: false]
      --force-esbuild       Force the development server to use the 'browser-esbuild' builder when building. This is a developer preview option 
                            for the esbuild-based build system.                                                       [boolean] [default: false]
      --hmr                 Enable hot module replacement.                                                            [boolean] [default: false]
      --host                Host to listen on.                                                                   [string] [default: "localhost"]
      --inspect             Activate debugging inspector. This option only has an effect when 'SSR' or 'SSG' are enabled.               [string]
      --live-reload         Whether to reload the page on change, using live-reload.                                   [boolean] [default: true]
  -o, --open                Opens the url in default browser.                                                         [boolean] [default: false]
      --poll                Enable and define the file watching poll time period in milliseconds.                                       [number]
      --port                Port to listen on.                                                                          [number] [default: 4200]
      --prebundle           Enable and control the Vite-based development server's prebundling capabilities. To enable prebundling, the Angular 
                            CLI cache must also be enabled. This option has no effect when using the 'browser' or other Webpack-based builders. 
                                                                                                                                       [boolean]
      --proxy-config        Proxy configuration file. For more information, see
                            https://angular.dev/tools/cli/serve#proxying-to-a-backend-server.                                           [string]
      --public-host         The URL that the browser client (or live-reload client, if enabled) should use to connect to the development server.
                            Use for a complex dev server setup, such as one with reverse proxies. This option has no effect when using the      
                            'application' or other esbuild-based builders.                                                              [string]
      --serve-path          The pathname where the application will be served.                                                          [string]
      --ssl                 Serve using HTTPS.                                                                        [boolean] [default: false]
      --ssl-cert            SSL certificate to use for serving HTTPS.                                                                   [string]
      --ssl-key             SSL key to use for serving HTTPS.                                                                           [string]
      --verbose             Adds more details to output logging.                                                                       [boolean]
      --watch               Rebuild on change.                                                                         [boolean] [default: true]
Advertisements