sudo apt-get install -y nodejs npm
# Remove nvm
sudo rm -rf ~/.nvm
hash -r
# Remove latest node version
sudo npm uninstall -g n
# Remove n
cd ~/src/n && sudo make uninstall && cd .. && sudo rm -r n
# Remove latest nodejs version
sudo apt-get purge -y nodejs npm
# Remove nodejs-legacy version
sudo apt-get purge -y nodejs-legacy npm
sudo apt -y autoremove
# Remove nodejs files
sudo rm -rf /usr/local/lib/node_modules/npm
sudo rm -rf /usr/local/lib/node_modules/n
sudo rm -f /usr/local/bin/node
sudo rm -f /usr/local/bin/npm
sudo rm -f /usr/bin/node
sudo rm -rf /usr/local/n/versions/node
Any updated node version shall be uninstalled before installing nodejs-legacy.
sudo apt-get install -y nodejs-legacy npm
sudo apt-get purge -y nodejs-legacy npm
sudo apt -y autoremove
exit # close the session and restart to clear the path
cd ~/src
git clone https://github.com/tj/n.git
cd n
sudo make install
cd ..
sudo n lts
cd ~/src/n
sudo make uninstall
cd ..
sudo rm -r n
sudo apt-get install -y nodejs npm
sudo npm cache clean -f
sudo npm install -g n
sudo n lts
exit # close the session and restart to clear the path
nodejs -v
node -v
npm -v
cd ~/
git clone https://github.com/creationix/nvm.git .nvm
cd ~/.nvm
git checkout v0.33.9
. nvm.sh
nvm install node
nvm install v4.2.6
nvm install lts/argon
nvm use node # use the last node version
nvm use v4.2.6 # use nodejs-legacy
nvm install v6.14.1
nvm use v6.14.1
nvm ls
nvm ls-remote
sudo rm -rf ~/.nvm
hash -r
cd <directory where the node application is located>
sudo rm -rf node_modules
sudo rm -rf /usr/local/lib/node_modules/<package>
npm install
cd <directory where the node application is located>
sudo rm -rf /usr/local/lib/node_modules/<package>
sudo rm -rf node_modules
sudo npm install -g
Read node.js for further information.