Difference between ng add <package name> vs npm install <package name> in angular 6

Nimish goel picture Nimish goel · May 4, 2018 · Viewed 18.3k times · Source

As Angular6 has been released, They have added a new command ng add . Can anyone tell me what will be the difference between existing command npm install <package> and ng add <package>

Answer

Suren Srapyan picture Suren Srapyan · May 4, 2018

ng add

ng add <package> uses your package manager and installs the dependency. That dependency can have an installation script which can be used to do more job except the dependency installation. It can update your configurations, download another dependencies based on that one or create scaffold templates (with initial markup and logic).

To use ng add for a third party dependency, that team must provide schematics which describes the installation script. This can include some .scss or .css or related .js files to be included in the angular.json file.

In your provided link, you can install material package and also create some components with components

npm install

npm install <package> just installs the dependency.

For more Version 6 of Angular Now Available.