fbpx

Series: Introduction to the MEAN Stack

Before we develop a web application with AngularJS, I introduce you to Bower in this article . This tool is required to manage client-side frameworks.

Bower is a package manager designed by Twitter for client-side modules. However, it is itself a node module, which can be easily installed via npm. Since we want to use Bower as a command line tool, we will install it globally:

1
$ npm install  g bower

The latest version of Bower is at the time of writing 1.2.7.

The use of Bower is very similar to npm. With the following command you install AngularJS:

1
$ bower install angular

Afterwards, a folder is bower_components created in which there is another folder named angular . This includes the latest stable version of AngularJS in a single JavaScript file and once again the same file in minified form.

Bower has some general problems that should not be mentioned. It is younger than npm, inconsistent and not so widespread. While you are only downloading the finished JavaScript file via Bower, you would download the complete development folder with all source and build files at the framework Bootstrap. The Bower community is disagreeed about whether or not a Bower component should contain development files (build, tests, etc.). This problem can be solved manually because Bower uses Git internally and any Git repository can be installed via Bower. Thus, if necessary, you can always download the complete project folder. You should keep this inconsistent behavior in the back of your head. For us this is not relevant,

Similar to package.json npm, Bower offers bower.json the possibility to define the dependencies of a project to other modules declaratively. We do not need this file for our example. Here you can read how to bower.json use the. It is also package.json relevant when you work with other developers (so they can see the dependencies to other modules at a glance) and if you want to publish your project.

The uninstallation of a Bower component takes place analogously to npm with the following command:

1
$ bower uninstall angular

A global installation of a component is not possible with Bower.

Since we now know how to use Bower, we can devote ourselves to the next article AngularJS.


0 Comments

Leave a Reply

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