JavaScript package managers for Java programmers

22 May 2017

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.

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.

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

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

{

"name":"library-backbone",

"homepage":"https://github.com/vasileboris/library-backbone",

"authors":[

"vasile boris <boris@espressoprogrammer.com>"

],

"description":"",

"main":"",

"license":"",

"private":true,

"ignore":[

"**/.*",

"node_modules",

"src/main/external-resources/public/js/lib",

"test",

"tests"

],

"dependencies":{

"requirejs":"^2.3.3",

"jquery":"^3.2.1",

"text":"^2.0.15",

"jquery.i18n":"^1.0.4",

"jquery-i18n-properties":"^1.2.3",

"underscore":"^1.8.3",

"backbone":"^1.3.3"

}

}

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

1

2

3

4

{

"directory":"src/main/external-resources/public/js/lib"

}

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: