Node.js Foundations

Node.js turns JavaScript into a server-side runtime. That shift changes where code runs, how I/O behaves, and how you structure applications.

What Node is

Node is not a framework. It is a runtime built on the V8 engine plus APIs for files, networking, timers, and process control.

Use cases

  • Backend APIs and microservices.
  • CLI tools and automation scripts.
  • Build pipelines, dev servers, and project scaffolding.
  • Real-time applications that need sockets and event-driven I/O.

Why it matters

  • Use one language across frontend tools and backend services.
  • Build command-line tools and automation scripts.
  • Work with a huge package ecosystem through npm.
  • Choose simpler deployment models for small teams and fast iteration.

Runtime model

JavaScript source
  -> Node runtime
  -> V8 executes code
  -> libuv handles async I/O

What is specific to Node

  • process for environment, arguments, exit codes, and runtime metadata.
  • Built-in modules such as node:fs, node:path, node:http, and node:crypto.
  • CommonJS support alongside ECMAScript modules in modern projects.
  • File system access, stream handling, and server sockets that browser JavaScript does not expose in the same way.

Practice

  1. Explain the difference between a browser and a runtime.
  2. List three Node APIs you cannot get from plain browser JavaScript.
  3. Write one note about when Node is a good fit and when it is not.
  4. Choose one real project idea and decide whether Node would be a good fit.