Node.js Basics
JavaScript… outside the browser? Illegal. (It’s legal.)
▶ the lesson · narrated sketch video · tap for sound
the intro
Node.js runs JavaScript on your machine and on servers. You get the language you already know plus modules, npm packages, and access to files and networks. Most backend JavaScript jobs are Node jobs, so this is the on-ramp.
fun fact ✦
Node.js shipped in 2009 and made “JavaScript everywhere” real.
the docs
the deep dive
the ideas behind the video — concepts, diagrams, a walkthrough and the traps to avoid
Node is the browser talked out of the way. It takes V8, the same JavaScript engine Chrome uses, and swaps the page for the operating system: files to read, networks to listen on, processes to run. You write the language you already know and just get different superpowers.
same language, new superpowers
key terms
runtime
The program that executes your code. The browser is one runtime; Node is another for the same language.
node app.jsnpm
The package registry and tool that ships with Node. A million libraries, one install command away.
npm install expressmodule
One file of code you can import into another. Node ships built-ins like fs and http, no install needed.
import fs from "node:fs"package.json
The ID card of a project: name, dependencies, and the scripts that run it.
npm run devhow it works
- 1Install the LTS
Grab the Long Term Support version from nodejs.org. It is the stable one teams actually run.
- 2Start a project
npm init creates package.json, the file that tracks dependencies and scripts.
- 3Write and run
Put code in app.js and type node app.js. No browser, no build step, it just executes.
- 4Iterate with --watch
node --watch app.js restarts on every save. Built in since Node 18, so retire nodemon.
the code, explained
things no browser JavaScript can do
side by side
in Node
- reads and writes files
- listens on ports
- no window, no document
in the browser
- renders pages with the DOM
- sandboxed away from your files
- a tab crash is not your crash
Node runs your code on one thread. One slow synchronous call, a readFileSync or a giant JSON.parse or a sneaky while loop, and every connected user waits behind it. The event loop forgives nothing; keep it moving.
quick answers
Is Node really single-threaded?
Your JavaScript runs on one thread, yes. Node uses others behind the scenes for disk and network I/O, which is why async work does not block. CPU-heavy work does.
Do I have to learn a new language for backend?
No. Same JavaScript or TypeScript. What changes is the library: no DOM, but fs, http, and process instead.
Should I learn Bun or Deno instead?
They are credible and fast, but Node has the deepest ecosystem and the most job listings. Learn Node first; the skills transfer in an afternoon.
quick hits about Node.js Basics
short answers · interviews, tips, trivia & hidden gems