DEV Community

Md. Maruf Sarker
Md. Maruf Sarker

Posted on

How to Update Node.js to the latest version on Ubuntu

Nodejs Official Website

Step - 1:

1st of all you need to download the latest version of Nodejs from the official Nodejs website

Step - 2:

Go to the correct path using command line or GUI.
Using Command line

cd Downloads/node-v17.0.1-linux-x64.tar.xz/
tar -xf node-v17.0.1-linux-x64.tar.xz
Enter fullscreen mode Exit fullscreen mode

Check Current Node version

node --version
v14.17.0
Enter fullscreen mode Exit fullscreen mode

To upgrade

sudo n latest
Enter fullscreen mode Exit fullscreen mode

Check Updated Node version

node --version
v17.0.1
Enter fullscreen mode Exit fullscreen mode

Nodejs version Updated

If you are using graphical interface then go to the destination path. Click right button and select extract here. Open the bin folder.
Directories and files
right click and select open in terminal
To upgrade

sudo n latest
Enter fullscreen mode Exit fullscreen mode

Check Updated Node version

node --version
v17.0.1
Enter fullscreen mode Exit fullscreen mode

Nodejs version Updated
Thanks, if you like this article useful then smash the like button. Share it with your friends. Stay Tuned.

If you want to learn more about Linux Command Line then you watch my Playlist

Top comments (8)

Collapse
 
mdmarufsarker profile image
Md. Maruf Sarker • Edited

install nodejs whatever version it is
then type
sudo npm i -g n
sudo n stable

Now you good to go

Collapse
 
rzpanahi profile image
Reza Panahi

Saved me a lot of time. thank you

Collapse
 
mdmarufsarker profile image
Md. Maruf Sarker
Collapse
 
mrwil95 profile image
MrWil95

Hey guys, I followed these steps and ran these commands in my terminal but after restarting my terminal it still says nodejs --version is 10.19.0 and node --version is 15.13.0 which is odd because if I open my powershell command line my current version of nod is 16.13.2 which is what I want. Any ideas of what's going on?

Collapse
 
mdmarufsarker profile image
Md. Maruf Sarker • Edited

my nodejs version is also 10.19.0. and node version is 16.13.0.
Don't worry, you are not going to face any error because your node version is > 12

for installing the latest version open terminal and type sudo n latest
this is the easy way for download the latest version. On the otherhand there are some issue with the latest version. if you are learning react or other framwork you can face some error for this latest version.

so, your node version is ok. feel free to use it.

Collapse
 
kawsarkabir profile image
KAWSAR KABIR

thanks bro

Collapse
 
saadmangalib profile image
Md. Saadman Galib Rabbi

🤩🤩 thanks for sharing

Collapse
 
mdmarufsarker profile image
Md. Maruf Sarker

Welcome brother