Courses / Node.js: From First Script to Production / Chapter 3
Module 2 · Node.js basics · Chapter 3 of 27
Globals and Modules: process, CommonJS and ES Modules
Builds on Getting Started: What Node.js Is and Running Your First Script. Next up: Asynchronous Programming: Callbacks, Promises and async/await.
Part 1 · JavaScript in Node versus the browser
What is missing and what is added
A front-end developer who moves to the server finds the language familiar and the surroundings different. The differences fall into three groups: what Node leaves out, what it adds and what it shares with the browser.
Node runs the same language as the browser, but it has no page. There is no window, no document and no localStorage on Node 24 unless you turn on an experimental flag, because nothing is drawn and there is no user sitting at a tab. The code that makes sense on a server uses other objects instead: process describes the running program, Buffer holds raw bytes, and require or import loads other files.
Every JavaScript environment has one global object, the place where built-in names such as setTimeout live. The standard name for it is globalThis, and it works in browsers, Node and every other runtime. Node also keeps the older name global for the same object.
| Only in browsers | Only in Node | In both |
|---|---|---|
window, document |