简体   繁体   中英

Angular JS 2 Difference between npm and ng(Angular-Cli) (Built tool)

In angularjs 2 what is main difference between NPM and NG (anglular-cli). If By NPM if we can built our application and it will work then what is the need of NG Built (angular-cli).

npm start vs ( ng serve or ng built)

NPM is basically a package manager which acts as a dependency provider. If there are many small packages, required to build a large one, NPM is the one hotspot which will provide us with the packages. Angular-CLI is one of those packages. As far as NG is concerned, it is the core module of Angular. Whenever, an application is started,the NG module is loaded by deafult. The module itself contains the essential components for an AngularJS application to function.

Hope it helps!

npm start - If we use this cmd, it will run whatever we have defined for the 'start' command of the scripts object in package.json file. And this internally contains ng serve command in it.

ng serve - It builds the application & starts the web server.And ng serve is the reason behind the auto compilation when changes are made(ie when saved).It is related with angular cli.

Angular-cli is using npm. ng-cli provides a easier way to build angular2 based apps. Npm provides modules for your application (like bootstrap, primeng etc.) Angular-cli is really just a swiss army knife for angular developers. You obviously can use other bundling/building tools, but angular-cli has nice support and tweaked exactly for angular2 apps.

So the answer to the question:

If By NPM if we can built our application and it will work then what is the need of NG Built (angular-cli).

Should be: for your convenience.

If you have knowledge of maven,

NPM like maven,

NG like Java

Maven provide infrastructure and dependencies (jar) for java

Same NPM provide infrastructure and dependent packages for NG (angular)

Correct me if i am wrong...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM