9.8 — Checkpoint: environment setup
Checkpoint — and a special one: it happens outside this app, on your real computer. You’ll install Node, create a project from nothing, write a script that reads the environment and writes a file, run it from the terminal, and verify the exit code — the complete life cycle of everything Phase 9 taught.
This exact workspace is what Playwright installs into. (On an iPad right now? The dress rehearsal below covers you — the real install can wait for a computer.)
// the mission (on a real computer):
// 1 install Node LTS → node --version
// 2 mkdir first-node && cd first-node
// 3 npm init -y → package.json
// 4 create hello.js:
import { writeFileSync } from "node:fs";
const who = process.env.USER_NAME ?? "friend";
const line = `hello, ${who}!`;
console.log(line);
writeFileSync("hello.txt", line);
// 5 node hello.js
// 6 USER_NAME=Lijas node hello.js
// 7 cat hello.txt → hello, Lijas!
// 8 echo $? → 0The mission has eight boxes, and every one uses a lesson you already own. Nothing new gets taught today — that’s what makes it a checkpoint: 9.1’s runtime, 9.2’s terminal, 8.2’s npm, 9.3’s switch, 9.4’s env, 9.5’s files, all assembled into one working environment.
The deeper story, with the real names for things — this part is what turns “I saw it” into “I can explain it.”
Troubleshooting the two classic snags: “node: command not found” right after installing usually means the terminal was already open — close and reopen it so it re-reads its PATH (the list of folders the shell searches for commands). “Cannot use import statement outside a module” means box three’s "type": "module" line is missing — 9.3 told you this error’s whole story in advance.
Windows note: the inline NAME=value command form is a Mac/Linux shell feature. PowerShell splits it: $env:USER_NAME="Lijas"; node hello.js — and reads the last exit code as $LASTEXITCODE instead of $?. Same machine, different dialect (9.2’s shells).
What you did NOT need today is worth noticing: no bundler, no framework, no config beyond one JSON line. A runtime, a folder, a file, a terminal — that’s the irreducible core of every Node project, including the grandest test suite you’ll ever maintain.
Job note: “set up a project from scratch” is a real interview task for automation roles — and you just rehearsed it end to end. In Phase 11, npm init playwright@latest will do a fancier version of boxes three-and-four for you; now you’ll know exactly what it scaffolded and why.
⌨️ the dress rehearsal
Before (or instead of, for now) the real terminal: stage the entire hello.js mission in the sandbox — env-driven greeting, model-disk write, honest exit code.
requirements:
- Model the run:
envas{ USER_NAME: "Lijas" }and a model diskconst disk = {}(9.5’s trick). - Write
greet(env): buildhello, NAME!with a template literal, where NAME isenv.USER_NAMEwith the honest default"friend". - Run the mission: print
greet({})(the default run), then printgreet(env), then storegreet(env)on the disk under"hello.txt"and print what the disk holds there. - Finish like a good process: print the exit code —
0if the disk’s"hello.txt"now holds a value,1otherwise (a real check, not a bare 0).
when you press RUN, the console must show exactly:
✏️ Quick check 1
Fresh machine, Node just installed. Which command proves the install worked?
✏️ Quick check 2
hello.js reads process.env.USER_NAME ?? "friend". You run it with nothing set. What prints?
✏️ Quick check 3
The run succeeded. What does echo $? print?
🗣️ Now teach it back
Brief a friend through the whole setup mission from memory: install and verify, project + init (+ which line you add by hand and why), the script’s moving parts, the two runs, and the two verifications at the end.
Write it as if your friend is sitting next to you. Saved to your journal — future-you will use these notes to teach others.