Example 1 — Print to the console
const message = 'Hello from Node.js!';
console.log(message);
console.log('Node version:', process.version); 
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.
Runtime overview.
Ryan Dahl.
Event loop.
HTTP server.
APIs & tools.
Hands-on code.
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.
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.
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.
| Event | Year | Highlight |
|---|---|---|
| Node.js announced | 2009 | Ryan Dahl at JSConf EU |
| npm launched | 2010 | Package manager for Node modules |
| io.js fork | 2015 | Community-driven faster releases |
| Node.js + io.js merge | 2015 | Unified project under Node Foundation |
| OpenJS Foundation | 2019 | Node.js joins Linux Foundation |
| LTS releases | Ongoing | Even-numbered versions get long-term support |
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.
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.
Download the LTS (Long Term Support) build from nodejs.org, run the installer, then confirm everything works:
node -v
npm -v node -v — prints the Node.js version (e.g. v22.x)npm -v — prints npm version bundled with Node.js file, and run node filename.jsnpm init -y to create a package.json when starting a projectStart with the simplest program—print text to the terminal:
console.log('Hello World'); 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:
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.
Some common use cases for Node.js include:
Many global companies rely on Node.js for performance and developer productivity. Here are seven well-known examples:
Node.js is also common at startups and enterprises building APIs, BFF (backend-for-frontend) layers, and JavaScript-first engineering teams.
| Concept | What it does |
|---|---|
| Runtime | Executes JavaScript outside the browser |
| V8 engine | Compiles JS to fast machine code |
| Event loop | Schedules async callbacks without blocking |
| Modules | require() (CommonJS) or import (ESM) |
| npm | Install and publish third-party packages |
| Built-in modules | fs, path, http, crypto, etc. |
| package.json | Project metadata, scripts, and dependencies |
| Task | Command / code |
|---|---|
| Run a script | node app.js |
| Initialize project | npm init -y |
| Install package | npm install express |
| Import module (CJS) | const fs = require('fs'); |
| Import module (ESM) | import fs from 'node:fs'; |
| Read env variable | process.env.PORT |
Five starter programs after installing Node.js. Save each file, run with node filename.js, and read the terminal output.
const message = 'Hello from Node.js!';
console.log(message);
console.log('Node version:', process.version); 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');
}); 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.
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.
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.
A browser or app sends an HTTP request to your Node server on a port like 3000 or 8080.
Node registers the connection and runs your callback when data is ready—without blocking other clients.
Route handlers read the request, talk to a database or file system, and prepare a response.
Node writes headers and body back to the client; the connection may stay open for keep-alive or WebSockets.
http, fs, path), and the event loop.http.npm audittry/catch or .catch()process.env), not hard-coded keysconst and modern ES syntax supported by your Node versionnode_modules or .env files to version controlBefore 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.
Install Node.js, save the Hello World server, and visit it in your browser.
9 people found this page helpful