Node.js Introduction

Beginner
⏱️ 15 min read
📚 Updated: Jul 2026
🎯 5 Examples
V8 · npm · http

What You’ll Learn

This page is a self-contained introduction to Node.js—JavaScript on the server. You will understand what Node.js is, how it differs from browser JavaScript, and build your first programs from the terminal and over HTTP.

01

What is Node.js

Runtime overview.

02

Creator

Ryan Dahl.

03

Scalability

Event loop.

04

Hello World

HTTP server.

05

Use cases

APIs & tools.

06

Examples

Hands-on code.

🤔 What is Node.js?

Node.js is an open-source, cross-platform JavaScript runtime that lets developers run JavaScript on the server side of web applications—and on desktops, CLIs, and IoT devices—without a browser.

It uses an event-driven, non-blocking I/O model, which means Node.js can handle many concurrent connections efficiently without creating a new thread for every request. That design makes it a strong fit for APIs, real-time chat, streaming, and data-intensive apps.

Node.js ships with a huge ecosystem of packages through npm (Node Package Manager), the world’s largest software registry. You can install libraries for databases, authentication, testing, and more with a single command.

💡
Beginner tip

Think of Node.js as “JavaScript + superpowers for the server.” You already know the language from the browser; Node adds modules for files, networking, and processes.

👴 Who Is the Creator of Node.js?

The creator of Node.js is Ryan Dahl. He first presented Node.js at the European JSConf in 2009 and continued leading the project until 2012, when he handed maintenance to the open-source community under the OpenJS Foundation.

Dahl wanted a way to build high-performance web servers without the overhead of creating a new thread per connection. By combining JavaScript with an event loop and non-blocking I/O, Node.js changed how developers think about back-end development.

EventYearHighlight
Node.js announced2009Ryan Dahl at JSConf EU
npm launched2010Package manager for Node modules
io.js fork2015Community-driven faster releases
Node.js + io.js merge2015Unified project under Node Foundation
OpenJS Foundation2019Node.js joins Linux Foundation
LTS releasesOngoingEven-numbered versions get long-term support

📈 Is Node.js Scalable?

Yes, Node.js is generally considered a scalable technology. It is a lightweight, event-driven platform with a single-threaded, asynchronous programming model. That architecture lets one Node process handle thousands of simultaneous connections efficiently, which suits I/O-heavy workloads like APIs and real-time messaging.

You can scale Node.js horizontally by adding more server instances behind a load balancer, or vertically by giving a machine more CPU and memory. Tools like the built-in cluster module and process managers (PM2) help run multiple workers on one machine.

However, scalability depends on your whole system—application design, database choices, caching, networking, and how you handle CPU-bound tasks. Node.js is a good choice for building scalable applications, but it is not a guarantee of scalability on its own.

  • Great for — JSON APIs, WebSockets, microservices, SSR, CLI tools
  • Watch out for — heavy CPU work blocking the event loop (offload to worker threads or another service)
  • Combine with — Redis caching, message queues, and horizontal scaling in production

✍️ What Language Is Node.js Written In?

Node.js itself is written primarily in C and C++, with JavaScript used for higher-level APIs and bindings. The JavaScript engine at its core is V8, originally developed by Google for the Chrome browser.

When you write server.js, your JavaScript source is parsed and compiled by V8 into fast machine code. Node adds native bindings (written in C++) for filesystem access, networking, cryptography, and other system-level features exposed through built-in modules like fs, http, and crypto.

💻 Install and Verify Node.js

Download the LTS (Long Term Support) build from nodejs.org, run the installer, then confirm everything works:

terminal
node -v
npm -v
  • node -v — prints the Node.js version (e.g. v22.x)
  • npm -v — prints npm version bundled with Node
  • Create a folder, save a .js file, and run node filename.js
  • Use npm init -y to create a package.json when starting a project

📄 Hello World in Node.js

Start with the simplest program—print text to the terminal:

server.js
console.log('Hello World');

Hello World HTTP server

Here is a classic Node.js program that creates a web server using the built-in http module. When a client visits the URL, the server responds with Hello World:

server.js
const http = require('http');

const server = http.createServer((request, response) => {
  response.writeHead(200, { 'Content-Type': 'text/plain' });
  response.end('Hello World\n');
});

server.listen(8080, () => {
  console.log('Server running at http://127.0.0.1:8080/');
});

Save as server.js, run node server.js, then open the URL in your browser. For larger apps, most teams use Express.js instead of raw http.

🤔 Where Is Node.js Used?

Some common use cases for Node.js include:

  1. Web applications — fast, scalable backends, often with Express.js, Fastify, or NestJS
  2. Real-time applications — chat apps, online games, live dashboards, and collaboration tools using WebSockets or Socket.IO
  3. API development — REST and GraphQL services that expose data to web and mobile clients
  4. Microservices — small, independent services that compose into larger systems
  5. Command-line tools — scripts and CLIs that automate builds, migrations, and dev workflows
  6. Serverless functions — short-lived handlers on AWS Lambda, Vercel, or Cloudflare Workers

🌐 Top 7 Sites That Use Node.js

Many global companies rely on Node.js for performance and developer productivity. Here are seven well-known examples:

  1. Netflix — one of the world’s largest video streaming services
  2. LinkedIn — the world’s largest professional networking platform
  3. PayPal — a popular online payments system
  4. Uber — a leading ride-hailing and delivery company
  5. Walmart — one of the largest retailers in the world
  6. Medium — a popular online publishing platform
  7. Trello — a widely used project management tool

Node.js is also common at startups and enterprises building APIs, BFF (backend-for-frontend) layers, and JavaScript-first engineering teams.

🧰 Core Building Blocks

ConceptWhat it does
RuntimeExecutes JavaScript outside the browser
V8 engineCompiles JS to fast machine code
Event loopSchedules async callbacks without blocking
Modulesrequire() (CommonJS) or import (ESM)
npmInstall and publish third-party packages
Built-in modulesfs, path, http, crypto, etc.
package.jsonProject metadata, scripts, and dependencies

⚡ Quick Reference

TaskCommand / code
Run a scriptnode app.js
Initialize projectnpm init -y
Install packagenpm install express
Import module (CJS)const fs = require('fs');
Import module (ESM)import fs from 'node:fs';
Read env variableprocess.env.PORT

Examples Gallery

Five starter programs after installing Node.js. Save each file, run with node filename.js, and read the terminal output.

Example 1 — Print to the console

server.js
const message = 'Hello from Node.js!';
console.log(message);
console.log('Node version:', process.version);

Example 2 — Minimal HTTP server

server.js
const http = require('http');

http.createServer((req, res) => {
  res.writeHead(200, { 'Content-Type': 'text/plain' });
  res.end('Hello World\n');
}).listen(3000, () => {
  console.log('Listening on http://localhost:3000');
});

Example 3 — Read a file with fs

server.js
const fs = require('fs');

const text = fs.readFileSync('hello.txt', 'utf8');
console.log(text);

Create hello.txt with any text in the same folder before running.

Example 4 — Work with file paths

server.js
const path = require('path');

const file = path.join(__dirname, 'data', 'users.json');
console.log('Full path:', file);
console.log('Extension:', path.extname(file));

path.join builds cross-platform paths safely on Windows, macOS, and Linux.

Example 5 — Non-blocking async with setTimeout

server.js
console.log('Start');

setTimeout(() => {
  console.log('Timer finished (async)');
}, 1000);

console.log('End (runs before timer)');

This shows how Node schedules async work on the event loop without blocking other code.

🧠 How Node.js Handles a Request

1

Client connects

A browser or app sends an HTTP request to your Node server on a port like 3000 or 8080.

Request
2

Event loop picks it up

Node registers the connection and runs your callback when data is ready—without blocking other clients.

Non-blocking
3

Your code runs

Route handlers read the request, talk to a database or file system, and prepare a response.

Handler
=

Response sent

Node writes headers and body back to the client; the connection may stay open for keep-alive or WebSockets.

Summary

  • Node.js runs JavaScript on the server using the V8 engine and an event-driven model.
  • Created by Ryan Dahl in 2009; maintained today by the open-source community.
  • It scales well for I/O-heavy apps but still requires good architecture and infrastructure.
  • Core pieces: modules, npm, built-in APIs (http, fs, path), and the event loop.
  • Common uses: APIs, real-time apps, microservices, CLIs, and serverless functions.
  • Next step: learn Express.js to build routes and middleware faster than raw http.

💡 Best Practices

✅ Do

  • Use the LTS version of Node.js for stability in learning and production
  • Keep dependencies updated and audit with npm audit
  • Handle errors in async code with try/catch or .catch()
  • Use environment variables for secrets (process.env), not hard-coded keys
  • Prefer const and modern ES syntax supported by your Node version
  • Start simple with built-in modules before adding frameworks

❌ Don’t

  • Block the event loop with long synchronous CPU work in request handlers
  • Commit node_modules or .env files to version control
  • Run production servers as root or without a process manager
  • Ignore unhandled promise rejections—they can crash your app
  • Install every npm package without checking maintenance and bundle size
  • Skip learning JavaScript fundamentals before jumping into back-end frameworks

❓ Frequently Asked Questions

Node.js is an open-source JavaScript runtime that runs on servers and desktops—not in a browser. It uses Google's V8 engine and an event-driven, non-blocking I/O model, making it well suited for APIs, real-time apps, and CLI tools.
Yes. Node.js uses the same JavaScript language you write in the browser. Learn variables, functions, objects, and async basics first, then move to Node modules, npm, and building HTTP servers.
No. JavaScript is the programming language. Node.js is a runtime environment that executes JavaScript outside the browser and provides built-in modules for files, networking, and processes.
Download the LTS installer from nodejs.org for Windows, macOS, or Linux. Verify with node -v and npm -v in a terminal. Package managers like nvm are popular on macOS and Linux for switching versions.
npm (Node Package Manager) ships with Node.js. It installs open-source libraries from the npm registry, tracks dependencies in package.json, and runs scripts defined in your project.
Practice the built-in modules fs, path, and http. Then learn Express.js for routing and middleware, connect to MongoDB or PostgreSQL, and explore async patterns with Promises and async/await.
Did you know?

Before Node.js, JavaScript was almost exclusively a browser language. Ryan Dahl’s idea to pair JavaScript with non-blocking I/O helped create the full-stack JavaScript developer role—one language for front end, back end, and tooling.

Try It Yourself

Install Node.js, save the Hello World server, and visit it in your browser.

Continue to Express.js →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful