How to use the Angular CLI add command line

Created
Modified

Adds the npm package for a published library to your workspace, and configures the project in the current working directory (or the default project if you are not in a project directory) to use that library, as specified by the library's schematic.

For example, adding @angular/pwa configures your project for PWA support:

pwa
ng add @angular/pwa
ℹ Using package manager: npm
✔ Found compatible package version: @angular/pwa@latest.
✔ Package information loaded.
✔ Package successfully installed.
CREATE ngsw-config.json (624 bytes)
......
UPDATE angular.json (3882 bytes)
UPDATE package.json (1251 bytes)
UPDATE src/app/app.module.ts (789 bytes)
UPDATE src/index.html (475 bytes)
✔ Packages installed successfully.

For example you run the command ng add @angular/material, it will automatically install the package and configure in angular.json file too.

Install Angular Material
ng add @angular/material
ℹ Using package manager: npm
✔ Found compatible package version: @angular/[email protected].
✔ Package information loaded.

The Angular CLI add Help Commands and Options

Usage: 
  ng add <collection> [options]

Arguments:
<collection>
The package to be added.
Options:
--defaults
Disable interactive input prompts for options with a default.
--help default:false
Shows a help message for this command in the console.
--interactive
Enable interactive input prompts.
--registry
The NPM registry to use.
--skip-confirmation default:false
Skip asking a confirmation prompt before installing and executing the package. Ensure package name is correct prior to using this option.
--verbose default:false
Display additional details about internal operations during execution.

Related Tags