Angular CLI - ng run Command



The ng run command executes specific tasks or targets defined in the Architect section of angular.json file in your project. Here, the project is the name of the application. These targets are build, serve, test, and lint. Each target has a different configuration.

To trigger these tasks directly from the command line, you need to specify the project name, target, and optional configuration in the ng run command.

Syntax

The syntax for ng run command is as follows −

ng run <target> [option]

Arguments

Following is the argument of ng run command −

Sr.No. Argument & Syntax Description
1 <target> It is a String that specifies which Architect target should run. The format is ng run project:target[:configuration].

Options

The optional parameter is −

Sr.No. Option & Syntax Description
1 --help=true|false|json|JSON

Shows a help message for this command in the console.

Default: false.

Example

If we use build target with ng run command, it will build the specified angular application. In the following example, this command is used to build form-app project. You will also see the location where the build file is stored in the project.

PS D:\Angular\form-app> ng run form-app:build
Initial chunk files   | Names         |  Raw size | Estimated transfer size
main-YREFOEEY.js      | main          | 227.39 kB |                59.49 kB
polyfills-FFHMD2TL.js | polyfills     |  34.52 kB |                11.28 kB
styles-5INURTSO.css   | styles        |   0 bytes |                 0 bytes

                      | Initial total | 261.91 kB |                70.77 kB

Application bundle generation complete. [10.633 seconds]

Output location: D:\Angular\form-app\dist\form-app
Advertisements