In this particular article, we’ll go through how to set up Grunt, Bower and Yo. The installation itself is very easy. You need to run the command
npm install -g yo, which uses NodeJS to install Yo globally. Yo has Bower and Grunt as dependencies, so at that point it’s all done.
If you did not install Sass, you probably want to update and install the pre-requisites:
sudo apt-get update sudo apt-get upgrade sudo apt-get install build-essential openssl libssl-dev curl
Taking a leaf from Ruby and RVM, the project will be cloned into a hidden folder named
.nvm under your home folder:
git clone git://github.com/creationix/nvm.git ~/.nvm
You will need to make sure that NVM is loaded when you open a terminal, through the following line:
echo '[[ -s "$HOME/.nvm/nvm.sh" ]] && source "$HOME/.nvm/nvm.sh"' >> ~/.bash_profile
To be able to use NVM directly, run
. ~/.nvm/nvm.sh, which will load it into the current shell session.
First, find which version of NodeJS is the current one, most easily accomplished by surfing to NodeJS homepage. At the time of the writing, it is v0.10.20.
It might take a bit to install NodeJS, 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
NPM is the package manager for NodeJS (what a shocker, eh?), with the homepage (and index of packages) at NPMJS. It occasionally feels somewhat meta that we will install a package manager (NPM) so that we can install another package manager (Bower), but that is an article for another day.
Oh, look, another cURL script being fetched and then piped through sh!
curl https://npmjs.org/install.sh | sh
How to use NPM
As noted above, the command to install Yo and it’s dependencies Grunt and Bower is
npm install -g yo. More often than not, you will want to keep the Node packages local to whichever project you’re in, but if you use the
-g switch, it will install that particular package globally, IE accessible to all projects.
Another useful command is
npm list which lists all the packages installed in that project or, with the
-g switch, globally.
Congratulations, you are now all done and have Grunt, Bower and Yo properly installed!