Node.js for beginners: what it is and how to get started

If you already write a bit of JavaScript for your web pages, you have probably come across Node.js without being entirely sure what it is. The good news: the idea is simpler than it sounds, and it opens up a whole side of development that the browser alone cannot reach. Let's look at what Node.js is, why so many developers rely on it, how to install it cleanly and how to launch your very first server.

What exactly is Node.js?

For a long time, JavaScript lived only inside the browser: it animated pages, reacted to clicks, validated forms. Node.js changes that by taking JavaScript out of the browser and running it directly on your machine or on a server. In practice, it is a runtime built on Google Chrome's V8 engine, the same one that interprets your code on the browser side.

Node's defining trait is its non-blocking behaviour. Instead of waiting for one task to finish before moving to the next, it lines up operations and handles each response as it arrives. This model, organised around an event loop, makes it very comfortable handling a large number of simultaneous connections without running out of breath.

Why so many developers adopted it

The first reason is comfort: one language from start to finish. The same JavaScript powers the visible part in the browser and the logic on the server. You spend less time switching between different syntaxes, and code travels more easily between the two worlds.

Then comes the ecosystem. With npm, the package manager bundled with Node, you get access to hundreds of thousands of ready-made libraries: a web server, a database connection, an image-processing tool. A single command line is usually enough to install them. For real-time uses such as a chat app, a dashboard that updates on its own or an API that needs to respond quickly, Node feels right at home.

If you are just starting out, you will also find plenty to round out your toolbox in our piece on the essential tools every web developer needs.

Installing Node.js the easy way

Head to the official site nodejs.org and download the LTS version (Long Term Support). It is the stable release recommended for most projects: it gets security updates for a long time, without the surprises of the very latest features.

Once the installation is done, open a terminal and check that everything is in place with these two commands:

node -v
npm -v

Each should print a version number. If so, Node and npm are ready. For anyone who will one day juggle several projects that require different versions, a manager like nvm lets you install and switch between Node versions in a single command, but it is not essential to get started.

Your first server in a few lines

The best way to understand Node is to watch it run. Create a file called server.js and paste this small program into it:

const http = require('http');

const server = http.createServer((request, response) => {
  response.statusCode = 200;
  response.setHeader('Content-Type', 'text/plain; charset=utf-8');
  response.end('Hello from Node.js!');
});

server.listen(3000, () => {
  console.log('Server listening on http://localhost:3000');
});

Run it from the terminal with node server.js, then open http://localhost:3000 in your browser. The message appears: you have just created a web server, with no external dependency, using only what Node ships with out of the box.

Where does npm fit in?

As soon as your project grows, you will lean on npm. The npm init command creates a package.json file that describes your project and keeps track of its dependencies. To add a library, npm install followed by its name is enough. Many beginners install Express, for instance, a lightweight framework that simplifies writing servers and handling routes, once the basics of the http module are clear.

Where to go next

You now have the foundations: you know what Node.js is, why it caught on, how to install it and how to launch a server. The next step is to work with npm, discover Express and connect a database. To keep your JavaScript sharp along the way, nothing beats a small hands-on project such as recreating the Snake game in vanilla JavaScript.

Which project would you most like to put Node.js to the test on first?

Recent Posts

Recent Comments

"

Itamde is also an online programming school.

Itamde

Learn what you want, at your own pace

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

You may also be interested in...

Web

Behind the Scenes of a Web Development Project

When you visit a finished website, you only see the final result: clean pages, smooth animations, well-organized content. But behind this facade lies a far more complex creation process, made up of strategic thinking, technical decisions, and collaboration between...

Stay up to date with the latest news and developments

Access restricted content

Discover behind-the-scenes details of our projects, exclusive resources, and the progress of our creations in real time.

Sign up for our newsletter

Receive our news, creative insights, and updates from the studio directly in your inbox.

Follow us

Join our community on social media to follow our daily projects and interact with us.