The first challenge I had, how do I install bower? The website of bower mentions npm, a package manager combined with NodeJS.
First the platform specific package management
Then, how do I install node? Of course I want to use a package manager, but since node is compiled per platform (it can’t be turtles all the way down) we have to use the package manager per platform. If you’re using Linux you most likely will be familier with Yum (Redhat, CentOS) or the apt-get (Debian, Ubuntu) . Typing:
sudo yum install node
sudo apt-get install node
is enough to install node.
Note: I’ve added sudo to every command because you’ll need root/admin rights to install the application.
I’m currently using a mac, and then the best package manager to use is Homebrew. It’s not installed by default, but if you go the Homebrew website you’ll have the tool up and running quickly.
After that I can install node via:
brew install node
I don’t use sudo: brew only stores files in /usr/local and I’ve set that directory to be writeable for admin-users. If you think that’s a security risk, you shouldn’t use brew at all.
If you’re a Windows use, you can use nu-get to install nodejs, but I don’t have experience with that tool yet.
If you don’t want to use any package-manager, then install node the more traditional way by downloading the installation package from the Node.js website.
Package management with Bower
Now node is installed I can use npm to install bower:
npm install bower
With have bower installed, I can fetch angularjs.
First I’ll create a directory where my application can reside, then I’ll use bower to add angular to my application.
bower install angular
The angular library is now available in the directory I’ve just created. The angular.js file can be included just as you’d normally include js files.
The components contains all the js files used by the applications. If you delete the directory, executing bower install will reconstruct the whole directory based on the bower.json file, so that’s the only file that we need to check to get our libraries.
Part of the build
The complete project I’ve created while writing this posting is available at my public github-account.