Angular CLI - ng add Command


Advertisements

This chapter explains the syntax, argument and options of ng add command along with an example.

Syntax

The syntax for ng add command is as follows −

ng add <collection> [options]

ng add a npm package to workspace.

Arguments

The argument for ng add command is as follows −

Sr.No. Argument & Syntax Description
1 <collection> The name of the package to be added.

Options

Options are optional parameters.

Sr.No. Option & Syntax Description
1 --defaults=true|false When true, disables interactive input prompts for options with a default.
2 --help=true|false|json|JSON

Shows a help message for this command in the console.

Default: false

3 --registry=registry The NPM registry to use.
4 --verbose=true|false

Display additional details about internal operations during execution.

Default: false

First move to an angular project updated using ng build command,which is available at https://www.tutorialspoint.com/angular_cli/angular_cli_ng_build.htm.

Now run the add command.

Example

An example for ng add command is given below −

\>Node\>TutorialsPoint> ng add @angular/pwa
Installing packages for tooling via npm.
Installed packages for tooling via npm.
CREATE ngsw-config.json (620 bytes)
CREATE src/manifest.webmanifest (1352 bytes)
CREATE src/assets/icons/icon-128x128.png (1253 bytes)
CREATE src/assets/icons/icon-144x144.png (1394 bytes)
CREATE src/assets/icons/icon-152x152.png (1427 bytes)
CREATE src/assets/icons/icon-192x192.png (1790 bytes)
CREATE src/assets/icons/icon-384x384.png (3557 bytes)
CREATE src/assets/icons/icon-512x512.png (5008 bytes)
CREATE src/assets/icons/icon-72x72.png (792 bytes)
CREATE src/assets/icons/icon-96x96.png (958 bytes)
UPDATE angular.json (3803 bytes)
UPDATE package.json (1332 bytes)
UPDATE src/app/app.module.ts (682 bytes)
UPDATE src/index.html (482 bytes)
√ Packages installed successfully.
Advertisements