How To Install Node.js and Check Node.js Version

JavaScript is one of the most common programming languages in the world. It now powers millions of websites and has drawn hordes of developers and programmers to create new web features. For novice programmers, JavaScript is unquestionably one of the finest languages to begin learning programming with.

JavaScript was primarily used for client-side programming for its first 20 years after release. Developers had to work between the front-end and back-end components in various languages and frameworks because JavaScript could only be used within the <script> tag. Later came Node.js, a run-time environment encompassing everything needed to run a JavaScript program.

In this article, you will learn the basics of Node.js as well as how to install it on your operating system and check the Node version running on your operating system.

What is Node.js

Node.js is a single-threaded, open-source, cross-platform runtime environment for building fast and scalable server-side and networking applications. It uses an event-driven, non-blocking I/O architecture and operates on the V8 JavaScript runtime engine, making it efficient and appropriate for real-time applications.

This V8 JavaScript engine makes it possible to build back-end applications using the same JavaScript programming language you may be familiar with.

Node.js was developed as a server-side platform by Ryan Dahl in 2009, and ever since then, it has continued to grow in popularity, evidenced by its cross-platforming. Node.js is not dependent on operating system software and can operate efficiently on Linux, macOS, or Windows.

Node.js is written in C, C++, and JavaScript. 

How to check the Node.js version

As stated earlier, Node.js offers cross-platform availability for Windows, macOS, and Linux operating systems. As such, depending on the operating system you choose, different caveats are involved. In this section, you will discover how to install Node.js and check the Node.js version running on your preferred operating system.

Windows

Step 1: Go to the official download site and select the Windows installer.

Step 2: After completing the download process, run the installer. The installer is the .msi file in your downloads directory.

Step 3: Follow the prompts in the installer (Accept the license agreement and accept the default installation settings).

Step 4: Restart your computer. You won’t be able to run Node.js until you restart your computer.

Step 5: Run the following command on the command prompt, and you can verify the installed version of Node.js on Windows: 

To confirm Node installation: node -v

To confirm NPM installation: npm -v

macOS

Step 1: Go to the official download site and select the macOS installer.

Step 2: Run the Node.js installer on your mac device. Follow the prompts in the installer. 

The steps involved are: Introduction > Continue License > Select Continue > Agree to Installation Type > Install > Authenticate with your Mac to allow the Installation > Install Software Summary > Close.

Step 3: To verify whether you have correctly installed Node.js in your macOS, run the following command in your terminal:

$ node -v 

Linux

The Linux operating system differs from other conventional operating systems in its operation. This is due to Linux being open-source. As such, you have more flexibility, customization, and advanced functionality. 

Here is the easiest method of installing Node.js on the Linux operating system.

Step 1: Choose the Node.js Version for Your Linux Distribution. Because of its variety, the Linux operating system has hundreds of various distributions. And users adore customizing and harnessing various versions’ specific functionalities using distinct distributions. First, find the installation instructions for your distribution from Node.js’s Binary Distributions page. For this guide, we’ll be using Ubuntu.

Step 2: Install the Curl Command-Line Tool. Before installing Node.js, ensure the curl command-line utility is installed on your system. If not, type the following code into your terminal to install curl: 

sudo apt install curl

Step 3: Start Node.js Installation. You need to copy and paste the Node.js installation command into your terminal (in our case, we can grab it from the Ubuntu distribution website) so that the system can initiate the Node.js installation.

These are the installation commands for Ubuntu:

curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash –

sudo apt-get install -y nodejs

As you already have the curl command line installed on your terminal, you’ll need to copy and paste the first command (the curl command) on your terminal and run it.

The curl command starts the Node.js installation process, updates your system, and downloads all Node.js libraries needed to install Node.js on your Linux operating system.

Now, all the libraries and resources of Node.js have been downloaded to your PC. With one final command, we can finish installing Node.js and npm on your computer.

Copy and paste the second line of command from the installation instructions above into your Linux terminal:

sudo apt-get install -y nodejs

If you follow all steps correctly, Node.js will install successfully on your Linux distribution. To clear the terminal, enter the Clear command.

Step 4: Verify Node.js Installation on Linux Ubuntu distribution. After you’ve installed Node.js, you can check to see if the installation was complete. You can execute two simple commands on your Linux terminal to confirm the installation.

To check the Node.js version, type:

Node –version

And to check the npm version, type:

npm –version

If the Node.js version and npm are correctly installed, the Node.js and npm version names will be visible in the Linux terminal. It shows that Node.js and npm have been successfully installed on your Linux distribution.

Conclusion

Over the years, Node.js has grown in popularity due to its numerous advantages for developing web-based and interactive web pages. As such, multiple versions have been created to cater to users of all operating systems. The installation processes for all operating systems supported by Node.js have been covered in this article, and how to check the version of Node.js your operating system is running.

Related Post

How to Install Laravel on Windows

Laravel is a popular open-source PHP framework designed...

How to Install Java on Windows

Java is a powerful programming language that is widely ...

Importing and Exporting Products in CSV Using

Starting an online store can be complex due to the time...

How to Install Laravel on Ubuntu 22.04

Laravel is a popular open-source PHP framework used for...

How To Update NPM Version – A Complete Guid

In the realm of web development and coding, utilizing l...

How to connect MySQL Database with PHP Websit

Integrating a MySQL database with a PHP website in web ...

Leave a Comment