Setting up a development environment starts with installing a version manager, so that we can install different versions and switch and test to versions we needed. For nodejs development environment, I start with installing node version manager, NVM.
The installation of NVM is quite simple, either you can run install script or do it manually by cloning the git repo. I find the install script as handy.
https://raw.github.com/creationix/nvm/master/install.sh | sh
OR you can clone the git repo
git clone git://github.com/creationix/nvm.git ~/.nvm
Then add the following to your .bashrc file. if you are using zsh, add to .zshrc file.
Install the node
Install the node versions you need.
nvm install v0.10.5
npm.js will be installed by default with nodejs version > 0.10.0
Switch the version you need using the command
nvm use v0.10.5
Now you can install the packages globally or locally, as your need. You won’t require to use sudo when installing packages globally.
npm install -g grunt-cli
Hooray, you are done. Try node on terminal to enter into node console.