I am installing latest version of nodejs in my localhost. But system is always installing the 4.2.6 version.How can i install the latest version.
Commands i have use
For me - the solution was on this page:
Ref: https://websiteforstudents.com/install-the-latest-node-js-and-nmp-packages-on-ubuntu-16-04-18-04-lts/
... for the Latest release, add this PPA..
curl -sL https://deb.nodesource.com/setup_10.x | sudo bash -
To install the LTS release, use this PPA
curl -sL https://deb.nodesource.com/setup_8.x | sudo bash -
Hey guys if you have Ubuntu 16 try this instructions. It worked for me perfectly.Also provide your account password whenever asked in this process.
sudo su -c "echo 'deb https://deb.nodesource.com/node_8.x xenial main' >> /etc/apt/sources.list.d/nodesource.list"
sudo su -c "echo 'deb-src https://deb.nodesource.com/node_8.x xenial main' >> /etc/apt/sources.list.d/nodesource.list"
sudo apt-get update
apt-cache policy nodejs Check if the versions listed has node 8
sudo apt-get install nodejs
nodejs -v check the node version installed
This shall successfully install nodejs version 8 on your system. If you wish any other version, then change the version on step 1 and 2 it shall work successfully.
sudo rm -rf /var/lib/apt/lists/*
sudo rm -rf /etc/apt/sources.list.d/*
sudo apt-get update
#Use this to remove the Previous Nodejs from Your device and then try again with Installing NVM
In Linux/Mac systems, there is no better way than nvm - Node Version Manager.
Install:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
Then, usage is as simple as:
nvm install 8.0
nvm use 8.0
If after reboot you will see old version, use nvm alias
to set your version as default one.
Current LTS instructions:
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get install -y nodejs
Courtesy of https://github.com/nodesource/distributions#installation-instructions