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 JavaScript
- Node.js LTS installed (Windows, macOS, or Linux)
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
| Topic | Browser | Node.js |
|---|---|---|
| UI | DOM, CSS, events | No DOM (use HTML files + browser for UI) |
| Global object | window | globalThis / global |
| Modules | ES modules in <script type="module"> | ES modules or CommonJS files |
| Storage | localStorage | Files, databases, Redis, etc. |
| Network | fetch (CORS rules) | fetch, http, TCP clients |
Core language features—functions, classes, Promises, arrays—work in both.
Run Your First Server Script (Preview)
// hello-server.mjs — run: node hello-server.mjs
console.log("Node version:", process.version);
console.log("Platform:", process.platform);node hello-server.mjsFull 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
// greet.mjs
const name = process.argv[2] ?? "Guest";
console.log(`Hello, ${name} from Node`);node greet.mjs AdaFAQ
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.