π’
EPISODE 01
Why Node? Β· install Β· REPL Β· running scripts
Node.js Basics
Run JavaScript outside the browser. Install Node, use the REPL, run scripts, and understand the runtime model and event loop at a high level.
Node.jsREPLevent loopruntime
Duration
β± About 1 hour
Level
π Beginner
Prerequisite
π― JavaScript basics
OUTCOME
Run JavaScript files from your terminal with Node
What you'll learn
- 1Install Node (LTS) and verify versions
- 2Run scripts with node file.js
- 3Use the REPL for quick experiments
- 4Understand the event loop in plain English
1. What is Node.js?
- A runtime that executes JavaScript outside the browser (built on V8)
- Single-threaded event loop with non-blocking I/O
- Used for servers, CLI tools, build tooling, and more
2. Install
bash
# https://nodejs.org β install LTS
node --version # v20.x or newer
npm --versionπ‘
Use nvm (Node Version Manager) if you work on multiple projects with different Node versions.
3. Run JavaScript
javascript
// hello.js
console.log("Hello from Node!");
console.log("Node version:", process.version);bash
node hello.js
node -e "console.log(2 + 2)" # one-liner
node # interactive REPL4. The Event Loop (Simple Mental Model)
- JavaScript runs on a single main thread
- Async operations (I/O, timers) are handed off to the platform
- When they finish, callbacks are queued and run on the main thread
- So your code never blocks waiting β but heavy CPU work still does
Example code / lecture materials
All lecture materials and example code are openly available on GitHub.
View on GitHub β