Reputation: 33
I had installed node and npm via :
$sudo apt-get install npm
then I realised the node version was 4.2.6, which I could not run my code ( some function syntax errors/ type erros etc.)
So I set to uninstall nodejs:
sudo apt-get remove npm
sudo apt-get purge nodejs
sudo apt-get autoremove
rm -r /usr/local/bin/npm
rm -rf ~/.npm
rm -rf /opt/local/bin/node
rm -rf opt/local/include/node
rm -rf /opt/local/lib/node_modules
Installing again with latest LTS, I am following install instructions from https://nodejs.org/en/download/package-manager/
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
My Question: After above install nodejs version is still 4.2.6, How can I get the latest version ? Or uninstall and clean the 4.2.6 ?
Upvotes: 2
Views: 10637
Reputation: 1978
You can install node using NVM (Node Version Manager)
Do this:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash
this will download and execute the NVM installation script. NVM should now be installed.
After that just use it to install node. Open a new terminal and for example do
nvm install 6.11.4
This installs node version 6.11.4, which is the latest LTS. You can install any version you want. Do
nvm ls-remote
to see all available versions and just replace the version number.
You can install any number of node versions, and switch between them using
nvm use 6.11.4
also you can set a default version using
nvm alias default 6.11.4
Upvotes: 5
Reputation: 1920
Go to node.org website
download binaries
unpack it
replace original files with unpacked content
for example
sudo mv ./bin/* /usr/bin/
sudo mv ./lib/* /usr/lib/
etc ...
Upvotes: 0