how to install latest version of nodejs in Ubuntu
You can try using Node Version Manager (NVM). You can find it on github here.
Briefly information to install nvm
and node
(see github repository for more information):
-
Install
nvm
:wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
-
Update Ubuntu environment variables. This commands let you run
nvm
from any place inside your terminal:export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
-
Check nvm is installed:
nvm --version
-
Install latest version of
node
(version selected by default):nvm install node
-
Check
node
version:node -v
Note: if you aren't be able to open node the first time, try to close and reopen your shell.
Remove the Previous one using:
sudo apt-get remove nodejs npm
Re install using PPA(Current Release):
sudo apt-get install python-software-properties
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
For LTS:
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
Facing the same issue not able to update from 5.12.0 to 6.x LTS version.But resolved it by following the instructions as mentioned in Nodejs.org
No need to remove the older version and all.
For upgrading to 6.x version: Run the below commands:
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
For upgrading to 8.x version: Run the below commands:
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs