Today I am going to show How to install Nodejs on your ubuntu machine of any version, you can install multiple versions of nodejs at same time using nvm.
nvm is to node what rbenv is to ruby, nvm helps us to use multiple versions of node on project level and over all system wide level, We will be using nvm to install because ubuntu does not have latest version of node. This is the easiest method of all and to stay updated on latest release of node, lets install nvm
git clone https://github.com/creationix/nvm.git .nvm
Now we need to source the nvm directory and nvm.sh to the shell, Add below lines to your
~/.bashrc, ~/.profile, or ~/.zshrc based on the shell you use, so that the command will be available on you login
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
Now get the list of available versions of nodejs
Based on your requirement, install the node version i will go for LTS version
nvm install v6.10.0
Set this version as default
nvm alias default v6.10.0
Now Nodejs is installed
You also have access to npm (Node Package Manager) you can get many node packages with single command lets check its version
Now suppose any of your project depends on older version of node then run this in specific project directory
echo "4.8.0" > .nvmrc