Posted in Uncategorized

Install and Switch node.js versions in Ubuntu


Node.js has a short release cycle which is good but sometimes it breaks things and deprecates a lot of stuffs.So, as a developer we would like maintain different versions of node.js. nvm is a handy tool to do that. We can install any version of node.js and also switch to a version accordingly. Let’s try nvm and switch versions
To install nvm

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

To load nvm

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
 source ~/.bashrc

– Now to install a node.js version  say 6.3.1.

   nvm install v6.3.1

– To switch  to a version

nvm use v6.3.1

– To see the list of installed versions

nvm list

The currently used version is v6.3.1 marked by ->

->       v6.3.1
         v6.9.5
         v7.4.0
         system
node -> stable (-> v7.4.0) (default)
stable -> 7.4 (-> v7.4.0) (default)
unstable -> 6.9 (-> v6.9.5) (default)
iojs -> iojs- (-> N/A) (default)

– To remove a version

nvm uninstall v6.3.1