Reputation: 123
I have an issue on my Ubuntu VM. I have tried several methods of updating to the latest Nodejs version (both LTS and Current), but running node --version
still shows v4.8.4.
I have tried using both n
and nvm
to update, as well as manually downloading and building. No matter what, v4.8.4 seems to be the only version running.
If I run which node
I get ~/.nvm/versions/node/v8.2.1/bin/node
. This looks correct, but node --version
is still v4.8.4.
How can I fix this?
Upvotes: 4
Views: 15920
Reputation: 189
You can:
sudo apt-get remove nodejs
Then:
sudo apt-get update
sudo apt-get install nodejs
sudo apt-get install npm
Check if it was updated
nodejs -v
Upvotes: 2
Reputation: 41
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs
Only this one is working the rest of the methods are not useful for the node
Upvotes: 4
Reputation: 115
In Ubuntu 16.04 its works:
Edit or create the file :nodesource.list
sudo gedit /etc/apt/sources.list.d/nodesource.list
Insert this text:
deb https://deb.nodesource.com/node_10.x bionic main
deb-src https://deb.nodesource.com/node_10.x bionic main
Run these commands:
curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -
sudo sh -c "echo deb https://deb.nodesource.com/node_10.x cosmic main /etc/apt/sources.list.d/nodesource.list"
sudo apt-get update
sudo apt-get install nodejs
Upvotes: 2
Reputation: 123
Thank you everyone for trying to help. The link @ScottStensland provided above (https://askubuntu.com/questions/426750/how-can-i-update-my-nodejs-to-the-latest-version) solved the issue for me. I needed a link!
sudo ln -sf ~/.nvm/versions/node/v8.5.0/bin/node /usr/bin/nodejs
Upvotes: 3
Reputation: 59
Have you tried cleaning your cache and re-installing using a clean version?
Using Command Line/Terminal:
sudo npm cache clean -f
sudo npm install -g n
sudo n 0.8.11
sudo n stable
node -v
node -v will check for the current version of node.js installed on your system.
In addition you can try installing globally using:
npm install npm@latest -g
Or manage your NPM versioning using at https://github.com/creationix/nvm:
nvm use system
nvm run system --version
nvm install node
Hope this helps!
Upvotes: 0
Reputation: 830
It's unclear what you have already tried - "I have tried several methods" isn't enough information for me to help you. But I will give it a try ;-)
You should know which Ubuntu version your virtual mashine offers. Just type in your terminal: lsb_release -a
Now you are free to follow the instructions from:
or: Installing Node.js via package manager
Upvotes: 0