Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot update Node in Ubuntu

I installed Node.js on my Ubuntu machine. I typed node but it didn't work. I typed nodejs and it worked. When I asked for the version, node -v didn't work but nodejs --version worked, it gives me "v0.10.25."

I updated Node from https://davidwalsh.name/upgrade-nodejs by using the commands sudo npm cache clean -f, sudo npm install -g n, and sudo n stable.

Still it's not working. What should I do?

enter image description here

like image 993
user2200091 Avatar asked Aug 08 '26 03:08

user2200091


1 Answers

I would suggest uninstall previous version and install your desired version from scratch.

To uninstall old version:

Run this command in your terminal:

lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do  sudo rm /usr/local/${f}; done

sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*

To install new version:

You can download both LTS and Beta version from the official site of node.js

But the best way would be using NVM. This would help you install and use multiple version of node on a single machine.

You can also use n. Which is similar to NVM but it's lightweight.

like image 84
Sk Arif Avatar answered Aug 10 '26 18:08

Sk Arif



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!