Every JavaScript program you've written so far runs inside a browser — a webpage loads it, and the browser's built-in JavaScript engine executes it. Node.js takes that same engine out of the browser entirely, so JavaScript can run directly on a computer, as its own standalone program.
Every browser has a JavaScript engine buried inside it — Chrome's is called V8. V8's job is to read JavaScript code and turn it into instructions the computer can actually run. It doesn't care where the code came from; it just executes it.
Node.js is built around that same V8 engine, wrapped with extra tools for things a browser deliberately doesn't allow: reading and writing files, listening for network connections, talking to a database. The language is identical — the same variables, functions, and syntax you already know — only what it's allowed to touch changes.
The two environments give JavaScript access to different things, because they solve different problems.
| Runs where | Can access | Cannot access | |
|---|---|---|---|
| Browser JavaScript | Inside a webpage | The page's HTML/CSS (the DOM), browser APIs | The computer's file system, arbitrary network ports |
| Node.js | Directly on a computer | Files, the file system, network connections, environment variables | A DOM — there is no page or window to manipulate |
This is why a Node.js program can never call document.querySelector() — there's no document. And why browser JavaScript can never read a file from your hard drive directly — letting a random webpage do that would be a serious security problem.
Because Node.js can read files, open network connections, and keep a program running indefinitely, it's well suited to exactly the things a browser can't do:
npm command you'll use in the next lesson is itself written in Node.js.Runtime, not a language
Node.js isn't a language — it's a runtime. The language is still JavaScript. Node.js is the program that runs it outside a browser, plus the extra built-in tools that make that useful.
You've already used JavaScript to make a webpage interactive on the visitor's side. Node.js is what lets that same language sit on the other side — the server — deciding what to send a visitor before their browser ever sees it. The rest of this course builds that up piece by piece: running scripts, organizing code into modules, reading files, and eventually building a real server that responds to requests.