In this, i am going to tell about two ways of installing Node on Ubuntu. Both are ways good, but if you have different applications which are running on different versions of Node, then you want to use the NVM approach
This will install the latest node version from NodeSource PPA
curl -sL https://deb.nodesource.com/setup_0.12 | sudo bash - sudo apt-get install -y nodejs
Above will install the 0.12 version of Node along with npm
Before using following command, make sure have
git installed on machine, if not run following use this tip to install same
After run following in terminal,
curl https://raw.githubusercontent.com/creationix/nvm/v0.11.1/install.sh | bash
This will download the script which installs
nvm on machine.
Now, close the terminal and open new one.
In new terminal, you will have access to
nvm command line tool
Will give help text on using nvm.
Now, we have to download the node onto machine, with the
nvm install 0.12.7
Above, will install node with version
Now, to use node with you have to do following -
$ nvm use 0.12.7 Now using node v0.12.7
Which will switch to
0.12.7 version of node and you will have access to
Now, if you close the terminal and again open and trying to access
node, you will get error.
nvm use only changes version to current shell.
To make default, you have to do following
nvm alias default 0.12.7
In which, we are setting default version of node to be used across globally.
There is unofficial port of windows exists with installer for same, refer the to this link for more - NVM for Windows