Skip to content

Node.js

A JavaScript runtime for building servers and tools outside the browser.

Runtime

Node.js runs JavaScript outside the browser, built on Chrome's V8 engine with an event-driven, non-blocking I/O model. It's what makes 'JavaScript on the backend' possible, and it underlies the entire npm ecosystem — build tools, meta-frameworks, and most JavaScript backend frameworks all run on Node (or a compatible runtime like Deno or Bun).

When to use it

  • You want one language (JavaScript/TypeScript) across frontend and backend
  • You're building I/O-heavy services (APIs, real-time apps) where Node's non-blocking model fits well
  • You need the largest package ecosystem (npm) for almost any utility need
  • Your meta-framework of choice (Next.js, Nuxt) already runs on Node, and you want backend logic in the same runtime

Considerations

  • CPU-heavy workloads (image/video processing, heavy computation) don't play to Node's strengths as well as languages built for that — worker threads help but add complexity
  • The single-threaded event loop means one long synchronous operation blocks everything else on that process
  • Framework choice on Node is fragmented (Express, Fastify, NestJS, Hono, and more) — no single obvious default the way some other ecosystems have one

Key concepts

Event loop

Node handles I/O (file, network) asynchronously via callbacks/promises rather than blocking a thread per request.

npm / package.json

The package manager and manifest file that define a project's dependencies and scripts.

CommonJS vs ES Modules

Node supports both require()-based CommonJS and modern import/export ES module syntax.

Streams

An abstraction for processing data (files, HTTP bodies) incrementally instead of loading it all into memory at once.

Getting started

npm init -y

Create a new package.json with defaults.

npm install express

Install a minimal web framework to start building an API.

Ecosystem

Express / Fastify / NestJS (frameworks)npm / pnpm / yarn (package managers)PM2 (process manager)Vitest / Jest (testing)

This guide states trade-offs, not a single "best" answer — the right choice depends on your team, constraints, and existing stack.