Upgrading Node Via NPM

The Problem: Need to upgrade node.

So OSX Mavericks is out, the update however broke my grunt. The solution I found is to upgrade to the latest version of node. The process of working with and administering node isn't always as straightforward as some other similar technologies. One such example is updgrading node itself. One would think that you could easliy do that via the NPM package manager like everything else but alas this is not the case by default ... but it's also not to hard to implement. ;)

The Answer: The n helper.

This comes to you courtesy of David Walsh.

sudo npm cache clean -f  
sudo npm install -g n  
sudo n stable  

The first line cleans the cache.
The next line installs the n node helper utility. The last line updgrades to whatever package you want. You could also conversely type:

sudo n 0.10.21  

To upgrade to the 0.10.21 version.

You can then check the version by running your standard:
node -v.