Node.js
backendnodejsCore ConceptBeginner
Introduction to Node.js
Understand Node.js, the V8 JavaScript engine, event-driven non-blocking I/O, and its role in modern backend systems.
Verified: 2026-09-30
Tested on:node 22.x
Platforms:
nodelinuxmacoswindows
#nodejs#backend#javascript#runtime#v8
What is Node.js?
Node.js is an open-source, cross-platform JavaScript runtime environment built on Google Chrome's V8 JavaScript engine. It allows developers to run JavaScript outside the browser to build scalable network applications, web servers, CLI tools, and automation scripts.
Key Characteristics
- Non-Blocking Asynchronous I/O: Operations such as file system access, network requests, and database queries are performed asynchronously without freezing the single execution thread.
- Event-Driven Architecture: Uses an event loop to orchestrate callbacks, promises, and events efficiently.
- Single-Threaded Event Loop: While Node.js processes user JavaScript on a single thread, background tasks (such as disk I/O and crypto) leverage a multi-threaded C++ worker pool (libuv).
- V8 Engine: Compiles JavaScript directly to native machine code at runtime for high execution speed.
- Rich Package Ecosystem: npm and pnpm offer over two million reusable packages.
Architecture Overview
+---------------------------------------------------------+
| Your JavaScript Code |
+---------------------------------------------------------+
| Node.js Core API |
| (fs, http, path, crypto, stream, events) |
+----------------------------+----------------------------+
| V8 Engine | libuv |
| (JS Execution & GC) | (Event Loop & Threads) |
+----------------------------+----------------------------+
| OS / Hardware |
+---------------------------------------------------------+When to Use Node.js
Node.js is an ideal choice for:
- REST APIs & Microservices: Fast JSON serialization and high concurrency.
- Real-Time Applications: Chat apps, live collaboration boards, and WebSocket servers.
- Single-Page Application (SPA) Backends: Next.js, Express, Fastify, and NestJS.
- Developer Tooling & CLIs: Build tools, bundling scripts, and command-line utilities.
- I/O-Intensive Workloads: Streaming video, proxying requests, and data pipeline aggregation.
Node.js vs Browser JavaScript
| Feature | Browser | Node.js |
|---|---|---|
| Global Object | window, document | global, process |
| DOM Manipulation | Supported (document.getElementById) | None (Headless runtime) |
| File System Access | Restricted sandbox | Direct OS access (node:fs) |
| Network Capabilities | fetch, XMLHttpRequest, WebSocket | Raw TCP/UDP sockets, HTTP servers |