When I worked with Java projects I never thought too much about dependencies management. I started to build projects with ant, I used to make it work but I never liked it because I had to manually manage the dependencies and the configuration was too verbose and error prone. Maven was like a breath of fresh air compared with ant. Dependencies were handled automatically and the configuration was almost none for simple projects. Even if I would like to use something else, I will have to choose between three options: maven, gradle and ant with ivy.

This year I started a new journey as writing front end code with JavaScript. I created a personal project and in the begging I manually downloaded needed JavaScript libraries. After the project started to take shape I wanted to automatically handle dependencies management and here the fun begun. If you don’t believe me just google for JavaScript dependency management and you’ find articles like 11 Dependency Management Tools for Web Developers or even better 13 best front-end package managers as of 2017 – Slant. Anyway, the first result that came from this search was:

Bower is a package manager for the web. Bower lets you easily install assets such as images, CSS and JavaScript, and manages dependencies.

I already knew about npm and after a search for bower vs npm bower seemed like the right choice because:

Npm and Bower are both dependency management tools. But the main difference between both is npm is used for installing Node js modules but bower js is used for managing front end components like html, css, js etc.

I jumped ahead on bower’s site, I followed the instructions to install it and then to add needed libraries. In the end I had two new files added to my project:

  • bower.json – The relevant information regarding this post is in dependencies section:

  • .bowerrc – I needed the directory attribute to install the libraries in a custom folder instead of the default bower_components:

The installation and configuration for this projects was a matter of 1 or 2 hours and it went without issues. The only funny aspect is that bower is a npm package itself. I wanted to find out more about it and then I noticed on bower site that:

…psst! While Bower is maintained, we recommend yarn and webpack for new front-end projects!

I just started to use a JavaScript package manager and it was already deprecated. Ant had its first release in 2000 and it is still relevant, bower was released in 2012 and it is already gone. Now I understand why JavaScript development is crazy.

I spent some time on google figuring out what I should do next and I decided to use yarn for the following reasons:

  • It is compatible with npm registry
  • It is backed up by facebook and google
  • It has its own life by having an installer for each operating system and not just beeing another npm package. What would you feel about gradle if you would need ant or maven to install it?

Installing and using was easy and the result was a new file named package.json. I had only one problem, I didn’t find jQuery.i18n.properties in yarn repository so I had to keep both yarn and bower and bower is called as a post install script.

  • bower.json:

  • package.json:

This is what I found until now on using JavaScript package managers, I hope that you enjoyed it and I’m waiting you to read my future posts.

Your thoughts are welcome

This site uses Akismet to reduce spam. Learn how your comment data is processed.