Introduction to Node.js

Setting Up Node.js

Let's see how you can create your first Node.js application. This section will show you how to run Node.js scripts from the command line.

How to download and install Node.js

First, you need to download and install Node.js. There are different ways you can do that. If you are a beginner, I suggest downloading Node.js from the official website.

[image]

Official packages are available on the website for all major platforms (Windows, macOS, and Linux). Download and install the appropriate package for your system.

After installing Node.js successfully, open your terminal and type the following command to confirm your installation.

node -v

If you see Node.js with version information as shown below, then you have successfully installed Node.js on your machine.

You can also confirm the version of NPM (Node Package Manager) that’s installed using the command below:

npm -v

NPM is always installed with a fresh version of Node.js; you don’t need to install it separately.

Create your first Node Application.

Now that you have Node installed let’s create our first Node application, open any text editor of your choice and type the following scripts in a new index.js file.

console.log("Hello World")

Next, open your terminal to the location of your index.js file and type the following command to compile and run your code:

node index.js

If everything is successful, you should be greeted with Hello World in your terminal as the output.

Of course, Node doesn’t end there. Next, let’s explore Node.js modules and look at some of the popular Node.js modules.

Whenever you're ready

There are 4 ways we can help you become a great backend engineer:

The MB Platform

Join 1000+ backend engineers learning backend engineering. Build real-world backend projects, learn from expert-vetted courses and roadmaps, track your learnings and set schedules, and solve backend engineering tasks, exercises, and challenges.

The MB Academy

The “MB Academy” is a 6-month intensive Advanced Backend Engineering BootCamp to produce great backend engineers.

Join Backend Weekly

If you like post like this, you will absolutely enjoy our exclusive weekly newsletter, Sharing exclusive backend engineering resources to help you become a great Backend Engineer.

Get Backend Jobs

Find over 2,000+ Tailored International Remote Backend Jobs or Reach 50,000+ backend engineers on the #1 Backend Engineering Job Board