NPM, Bower and Composer, which one to use?

Asked

Viewed 2,392 times

10

Can someone explain to me the difference between NPM, Bower and Composer.

They are all package managers, correct?

But when each must be used?

4 answers

17


Yes correct, they are all package managers. But, the type of packages they manage is different.

I can begin by explaining that Composer is a package manager focused on php (there are exceptions, for example you can also "install" jQuery but by convention and by habit people tend to choose Bower for this specific effect), if you internalize that Composer is for php (although there are exceptions) you will not make a fuss. While others are not for php packages.

As for the others they can be confused, yes, but I will try to make them cease to be.

Npm is mostly for managing Node.js packages/modules, it has some exceptions but usually these have the possibility to choose which to use, eg: https://vuejs.org/v2/guide/installation.html .

Bower is used to manage front-end packages, such as html, css (eg, bootstrap, etc.), javascript (e.g. Jquery, etc.), anything related to layout (code only interpreted by the browser, browser, not the server), often even entire templates can be downloaded with Bower, e.g. https://github.com/almasaeed2010/AdminLTE.

10

9

NPM is for projects in nodejs, if you are developing some project with Nodejs the best option is this.

Bower is for web project dependencies, focused on front-end, like jQuery (Bower needs nodejs to run)

and the Composer is a PHP-focused dependency manager.

There is another link in stackoverflow in English, where someone explains the difference a little better, follow the link: https://stackoverflow.com/questions/22918517/npm-bower-composer-differences

  • 2

    With Composer it is also possible to install dependencies, such as jQuery. It is focused on PHP, but can be used with other things .

  • @Wallacemaxters as I quoted in my reply ;)

  • @Guilhermenascimento, in fact it is true was sure that it was only php, apparently it was wrong :/... My mistake, and mine was accepted and not deserved

  • @Miguel not the problem Miguel, all answers were helpful, you can edit your and add the detail without problem, as long as you help the community see no problem ;)

  • 1

    Obagdo for letting me correct the reply @Guilhermenascimento, with information provided by you

5

npm is the nodejs package manager. Used in javascript projects and takes care of the javascript module dependencies of your project. See more on npmjs

commiserate is the backend package manager, most used in PHP, but there are other projects and CMS like drupal that Composer takes care of all the module dependency of the project. See more in commiserate

Bower is a front-end component manager, it is necessary to put it with npm. It manages the front-end dependencies of your project. See more in Boer.io.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.