Angular CLI – ng add Command

Angular CLI - ng add Command

In this Angular CLI ng add Command chapter explains the syntax, argument and options of ng add command along with an example. So all the Details of Angular CLI ng add Command explain below-

Syntax

The syntax for ng add command is as follows −

ng add <collection> [options]

ng add an npm package to the workspace.

Arguments

The argument for ng add command is as follows −

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

Options

Options are optional parameters.

Sr.No.Option & SyntaxDescription
1–defaults=true|falseWhen true, disables interactive input prompts for options with a default.
2–help=true|false|json|JSONShows a help message for this command in the console. Default: false
3–registry=registryThe NPM registry to use.
4–verbose=true|falseDisplay 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://adglob.in/blog/angular-cli-ng-build-command/,

Now run the add command.

Example

An example for ng add command is given below −

\>Node\>Adglob> 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.

Next Topic : Click Here

Leave a Reply