From install to globals — your first Node workflow
flowchart TD
A["<b>i · Install</b><br/>node + npm via LTS<br/>verify with node -v"]
--> B["<b>ii · REPL</b><br/>node ↵<br/>one line at a time"]
A --> C["<b>iii · File mode</b><br/>node app.js<br/>full file executed"]
B --> D["<b>iv · Node runtime</b><br/>V8 + Node APIs<br/>(the 'superpowers')"]
C --> D
D --> E["<b>v · global</b><br/>setTimeout, console,<br/>fetch, setImmediate"]
D --> F["<b>vi · globalThis</b><br/>universal reference<br/>(window ≡ global)"]
D --> G["<b>vii · top-level this</b><br/>= module.exports ({})<br/>NOT global"]
classDef setup fill:#f5efe1,stroke:#6a8a4f,stroke-width:2px,color:#1a1915;
classDef run fill:#fdecd3,stroke:#c2410c,stroke-width:2px,color:#1a1915;
classDef rt fill:#eaf2f8,stroke:#3a6ea5,stroke-width:2px,color:#1a1915;
classDef global fill:#ece5f5,stroke:#6b46c1,stroke-width:2px,color:#1a1915;
classDef gotcha fill:#fde8e8,stroke:#c53030,stroke-width:2px,color:#1a1915;
class A setup
class B,C run
class D rt
class E,F global
class G gotcha-
Install
Install the LTS build from nodejs.org — bundles Node + NPM. Verify with `node -v` / `npm -v`.
-
REPL
Interactive mode: type `node`, evaluate one line at a time. Great for quick experiments; nothing persists.
-
File mode
Write `app.js` in a folder, run with `node app.js`. The whole file executes top to bottom.
-
Node runtime
V8 engine + Node APIs (fs, http, net, os). Runs your code in either REPL or file mode.
-
global
Node's global object. Provides setTimeout, setInterval, setImmediate, console, fetch, queueMicrotask.
-
globalThis
ES2020 universal reference. In Node, `globalThis === global`. In browsers, `globalThis === window`.
-
top-level `this`
Trap: at the top level of a Node file, `this` is the empty `module.exports`, not the global object.
Comments
Comments are disabled in this environment. Set
PUBLIC_GISCUS_REPO,PUBLIC_GISCUS_REPO_ID, andPUBLIC_GISCUS_CATEGORY_IDto enable.