Installing Yeoman (Grunt, Bower and Yo) on Ubuntu

Yeo­man is a catch-all phrase (at this time) for Grunt (automa­tion), Bow­er (pack­age man­ag­er) and Yo (scaf­fold­er).

In this par­tic­u­lar arti­cle, we’ll go through how to set up Grunt, Bow­er and Yo. The instal­la­tion itself is very easy. You need to run the com­mand npm install -g yo, which uses Node­JS to install Yo glob­al­ly. Yo has Bow­er and Grunt as depen­den­cies, so at that point it’s all done.

The trick is, of course, the depen­den­cies. You need to have installed Git, and (assum­ing you’re inter­est­ed in my work­flow) Sass with Com­pass. The third impor­tant thing you need to install is Node­JS.

Preparations

If you did not install Sass, you prob­a­bly want to update and install the pre-req­ui­sites:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential openssl libssl-dev curl

Install NVM

Just as with Ruby, it’s occa­sion­al­ly a very good idea to ensure that one can use dif­fer­ent ver­sions. I use Node Ver­sion Man­ag­er by Tim Caswell and see no rea­son to change.

Tak­ing a leaf from Ruby and RVM, the project will be cloned into a hid­den fold­er named .nvm under your home fold­er:

git clone git://github.com/creationix/nvm.git ~/.nvm

You will need to make sure that NVM is loaded when you open a ter­mi­nal, through the fol­low­ing line:

echo '[[ -s "$HOME/.nvm/nvm.sh" ]] && source "$HOME/.nvm/nvm.sh"' >> ~/.bash_profile

To be able to use NVM direct­ly, run . ~/.nvm/nvm.sh, which will load it into the cur­rent shell ses­sion.

Install NodeJS

First, find which ver­sion of Node­JS is the cur­rent one, most eas­i­ly accom­plished by surf­ing to Node­JS home­page. At the time of the writ­ing, it is v0.10.20.

It might take a bit to install Node­JS, so be patient…

nvm install v0.10.20 #or whatever is the latest stable at your reading
nvm alias default 0.10.20 #sets the default assumption of any project to that

Installing NPM

NPM is the pack­age man­ag­er for Node­JS (what a shock­er, eh?), with the home­page (and index of pack­ages) at NPMJS. It occa­sion­al­ly feels some­what meta that we will install a pack­age man­ag­er (NPM) so that we can install anoth­er pack­age man­ag­er (Bow­er), but that is an arti­cle for anoth­er day.

Oh, look, anoth­er cURL script being fetched and then piped through sh!

curl https://npmjs.org/install.sh | sh

How to use NPM

As not­ed above, the com­mand to install Yo and it’s depen­den­cies Grunt and Bow­er is npm install -g yo. More often than not, you will want to keep the Node pack­ages local to whichev­er project you’re in, but if you use the -g switch, it will install that par­tic­u­lar pack­age glob­al­ly, IE acces­si­ble to all projects.

Anoth­er use­ful com­mand is npm list which lists all the pack­ages installed in that project or, with the -g switch, glob­al­ly.

Con­grat­u­la­tions, you are now all done and have Grunt, Bow­er and Yo prop­er­ly installed!


For the moment comments are not enabled, but feel free to reach out on Twitter.