Wednesday, July 15, 2015

Installing NVM And Node.js To Your Home Directory

On Fedora I've found that installing node.js and npm to be less than useful for my needs; i.e., while they install and work, they want to put things into the system directories and not my home directories. And, like with Ruby on Rails, you get locked into whatever is the latest version packaged for Fedora itself, which isn't always what you'd want.

What would be nice is to have something akin to RVM for Ruby, that lets you install the specific version you want regardless of what's packages for your release.

Enter NVM, the Node Version Manager. The name is even reminiscent of RVM! :D

To install this on my Fedora system, I first downloaded the nvm release script and executed it using:

 $ wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.12.1/install.sh | bash

and then sourced my .bash_profile, which was updated to include NVM.

 $ . ~/.bash_profile

I then checked to see what the latest version of node.js was to download and install

 $ nvm current
v0.12.7


so I could be sure to install the latest version, which I did:

 $ nvm install v0.12.7
######################################################################## 100.0%


Then, to use it, you type:

 $ nvm use v0.12.7

and you should now see node in your path:

  $ which node
~/.nvm/v0.12.7/bin/node