How to Check Node.JS Version in Ubuntu

Node.js is a cross-platform and open-source JavaScript runtime environment. Though it’s usually associated with web development along with building extensions for web browsers, Node.js can be used to build stand-alone applications. It enables developers to write scalable back-end code.

In this post, we will take a look at how can you install Node.JS on Ubuntu 20.04 and then how to make sure you are using the latest version.

Installing Node.JS

Installing Node.JS is a fairly simple process. All you need is ample space on your HDD and a user with sudo privileges. Now start up the terminal and type in the following:

$sudo

Sponsored
apt install nodejs

After providing elevated permissions to the terminal, you will be prompted by a similar output confirming if you are willing to use up 30.7MB of disk space on your hard disk drive.

When you confirm, the installation will proceed and return with the prompt once the installation has been completed.

If for any reason, the command given earlier isn’t working for you, you can check the detailed installation steps via multiple methods in our other post “How to install Node.js and Npm in Ubuntu”.

How to check the Node.Js version

Once you are done with the installation, or if you have Node.Js installed on your system and you want to know the installed version, you can simply type this:

$node -v

Knowing the version of Node enables you to leverage the features of each specific version whenever you need it. It specially comes in handy if you are following a tutorial and you need to have a specific version installed to complete it.

Upgrading Node.JS to a stable version

As a developer, usually the job entails playing around with experimental versions and finding out the exact features that you need for your project. If you are done with the experimentation and want to update Node.Js to the latest stable version, you need to execute these commands in the order they are mentioned.

$sudo npm cache clean -f

The “I sure hope you know what you are doing” prompt is just a warning and is nothing to worry about if you want to update npm to the latest version. Now run:

$sudo npm install -g n

Now run this finally:

$sudo n stable

Once this completes the execution, you will be on the latest stable version of Node.Js.

Why use Node.JS?

Though it has become the de-facto choice for many industries like healthcare, and IT along with many others, Node.JS is a versatile runtime yet it cannot be used for all the projects. Let’s take a look at the pros and cons, which could help us in understanding better where to use Node.JS and where not to.

Pros of Node.JS

Writing code in Node.JS delivers high performance for your real-time applications, which you can easily scale to your heart’s desire. It’s very cost-effective to develop using Node.JS. The quick caching mechanism makes it very easy for you to enhance the loading time of your applications. There is a very extensive support community if you ever get stuck at any point, which makes it very easy to learn and pick up.

See also  How to Install and Setup MERN Stack with Nginx on Ubuntu 20.04

Cons of using Node.JS

Node.JS cannot handle computing-intensive tasks well. Furthermore, due to an unstable API, you might need to keep changing your code to keep your project stable. Also, without extensive library support, your project can be endangered as the asynchronous model for programming in Node.JS makes it very difficult to maintain legacy code.

Conclusion

Going through all of these steps, you can see at each step which version of Node.JS is installed on your Ubuntu 20.04. Node.JS is very famous and quickly growing even more in popularity. You can learn a lot by experimenting around with the code.

If you run into any issues, please drop a comment below and let’s talk about it.

Karim Buzdar

Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications including CCNA RS, SCP, and ACE. As an IT engineer and technical author, he writes for various websites.

Leave a Comment

Only people in my network can comment.