Node.js is an extremely powerful JavaScript-based server-side platform used to develop I/O intensive web applications like video streaming sites, single-page applications, online chat applications, and other web applications. 

Node.js is used by large, established companies (Netflix, Paypal, NASA, and Walmart, to name a few) and newly-minted startups alike. The platform brings plenty of advantages to the table, making it a better choice than other server-side platforms like Java or PHP in many cases.

The following article covers the complete Node.js installation on Windows and Ubuntu. We’ll also create a basic Node.js server, in the end, to verify if everything is working properly.

Enroll for the Node.js Certification Training and learn to build network applications quickly and efficiently using JavaScript. Check out the course curriculum!

Node.js Installation on Windows

In this section, we'll be looking at Node.js installation on Windows. If you're an Ubuntu user, you can jump ahead to the next section that deals with Node.js installation on Ubuntu.

Steps to Install on Windows:

1. Download Node.js from https://nodejs.org/en/download/

2. Select the Windows installer according to your system environment (32-bit or 64-bit).

downloads

3. Run the downloaded Node.js installer. 

4. Accept the license agreement. You can leave other settings as default. The installer will install Node.js and prompt you to click on the finish button.

node-js-setup

5. Verify that Node.js was properly installed by opening the command prompt and typing this command: node --version

node-version

6. When we install Node.js, NPM (Node Package Manager) also gets installed. NPM is included in the installation as it includes many libraries that are used in web applications like React. So let’s verify if it's installed using this command in cmd: npm --version

npm-version

That’s all we need to do for a successful Node.js installation on a Windows system! If you're a Windows user, you can skip the next section and jump straight to the section in which we'll create a basic Node.js server to verify if everything works as expected.

Node.js Installation on Ubuntu

Here, we'll carry out Node.js installation on the Ubuntu system. 

Steps to Install on Ubuntu:

1. First, add the Node.js PPA to our system to install Node.js on Ubuntu:

sudo apt-get install curl

curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -

ubuntu-plat

2. Now run the below command to install Node using apt-get. This will also install NPM with Node.js:

ubuntu-platform

sudo apt-get install nodejs

3. Verify that Node.js and NPM are properly installed, by running this command:

node --version

npm --version

npm-version-2

Now that we’ve completed the installation of Node.js on both Windows and Ubuntu Operating Systems, let’s create a simple Node.js web server.

Creating a Simple Node.js Server

In this section, we'll create a simple Node.js web server. For this, we'll need a text editor, preferably VS Code or Atom. The code to create the server is as below:

var http = require('http');

http.createServer(function (req, res) {

  res.writeHead(200, {'Content-Type': 'text/plain'});

  res.end('Hey! You have successfully created a web server!!');

}).listen(3000, "127.0.0.1");

console.log('Server running at http://127.0.0.1:3000/');

Code explanation:

  • We declare a variable http that imports and contains the http module, which is required to interact with the web
  • HTTP module has a method called createServer that creates a server using a function with parameters req (request) and res (response)
  • We use the res (response) parameter to send a string to the web page
  • After that, we set the server to listen at port: 3000 and URL: “127.0.0.1”
  • We use the console.log method to log the output of the program in the cmd or terminal. If the program works fine, this method displays the string enclosed in the brackets
  • Finally, we save the file as server.js

We can now start the Node.js server that we just created using the command:

node server.js

Note: VS Code has a built-in terminal so you can run this command there.

vs-code

Since we get the String that we defined within the brackets of console.log method, we can see that Node.js server is now running and working as expected.

We can also check the response on the web page by going to the defined URL and port.

web-server

Since this also works absolutely fine, we can conclude that we’ve successfully installed Node.js in our system. 

Now the next logical step would be to start learning more about Node.js and eventually gain some hands-on knowledge about this very popular server-side platform.

Check out the video tutorial below to understand clearly the Node.js installation on Windows 10 and Ubuntu -

Learn for Free! Get access to our library of over 2000 learning videos. What are you waiting for?

”Get

Get Ahead of the Curve and Master Node.js Today

Now that you’ve learned about Node.js installation on Windows and Ubuntu, you may be wondering how you can obtain the skills necessary to take advantage of its rising popularity. 

Fortunately, there are some great options for learning this exciting and practical skill set at your own pace. Simplilearn’s Node.js Certification Training will give you a great foundation in this popular platform, combining live, instructor-led training, self-paced tutorials, and hands-on projects to help you become career-ready upon completion. Get started today to seize your future! 

Our Software Development Courses Duration And Fees

Software Development Course typically range from a few weeks to several months, with fees varying based on program and institution.

Program NameDurationFees
Caltech Coding Bootcamp

Cohort Starts: 16 Dec, 2024

6 Months$ 8,000
Automation Test Engineer Masters Program

Cohort Starts: 18 Dec, 2024

8 months$ 1,499
Full Stack Java Developer Masters Program

Cohort Starts: 18 Dec, 2024

7 months$ 1,449
Full Stack (MERN Stack) Developer Masters Program

Cohort Starts: 8 Jan, 2025

6 Months$ 1,449

Get Free Certifications with free video courses

  • Getting Started with Full Stack Development

    Software Development

    Getting Started with Full Stack Development

    12 hours4.551.5K learners
  • Full-Stack Development 101: What is Full-Stack Development ?

    Software Development

    Full-Stack Development 101: What is Full-Stack Development ?

    1 hours4.415K learners
prevNext

Learn from Industry Experts with free Masterclasses

  • Key 2025 Software Development Trends- Learn How To Leverage them for your career

    Software Development

    Key 2025 Software Development Trends- Learn How To Leverage them for your career

    9th Dec, Monday9:30 PM IST
  • Must-Know Full Stack Java Dev Career Trends for 2024

    Software Development

    Must-Know Full Stack Java Dev Career Trends for 2024

    6th Aug, Tuesday9:00 PM IST
  • Full Stack Java Development: A 2024 Blueprint for Recession-Proofing Your Career

    Software Development

    Full Stack Java Development: A 2024 Blueprint for Recession-Proofing Your Career

    27th Jun, Thursday7:30 PM IST
prevNext