Node.js Overview

Introduction

Node.js runs JavaScript on servers, CLIs, and build tools—not in a browser tab. The language syntax matches what you learned earlier; the APIs change (files, processes, HTTP servers instead of DOM). This chapter explains what Node is, how it differs from browser JS, and where it fits in full-stack work.

Prerequisites

What Is Node.js

Node.js is a runtime built on Chrome’s V8 engine. It executes .js files on your machine and provides system-level APIs:

  • Read/write files (fs)
  • Create HTTP servers (http, https)
  • Spawn child processes
  • Access environment variables (process.env)

npm (Node Package Manager) ships with Node for installing libraries.

Browser vs Node

TopicBrowserNode.js
UIDOM, CSS, eventsNo DOM (use HTML files + browser for UI)
Global objectwindowglobalThis / global
ModulesES modules in <script type="module">ES modules or CommonJS files
StoragelocalStorageFiles, databases, Redis, etc.
Networkfetch (CORS rules)fetch, http, TCP clients

Core language features—functions, classes, Promises, arrays—work in both.

Run Your First Server Script (Preview)

javascript
// hello-server.mjs — run: node hello-server.mjs
console.log("Node version:", process.version);
console.log("Platform:", process.platform);
bash
node hello-server.mjs

Full HTTP example in Node HTTP server.

Typical Node Use Cases

  • REST and GraphQL APIs
  • SSR and static site tooling (Next.js, Vite)
  • CLIs and automation scripts
  • WebSocket and streaming services
  • Background jobs and queues

Same Language, Different Ecosystem

Front-end bundles often target browsers; Node projects target server runtimes. You may share validation logic in a monorepo, but do not import document in server code or fs in browser code without bundler shims.

Mini Example: CLI Greeting

javascript
// greet.mjs
const name = process.argv[2] ?? "Guest";
console.log(`Hello, ${name} from Node`);
bash
node greet.mjs Ada

FAQ

Is Node “backend only”?

Mostly server-side, but also used for local dev tools that never deploy to a server process long-term.

Node vs Deno/Bun?

Alternatives with different defaults; this course uses official Node.js LTS.

Do I need a browser to learn Node?

No—terminal and an editor are enough.

What comes next?

ES modules.