Hiprup

Can you access the DOM in Node.js? Why or why not?

No, you cannot access the DOM in Node.js by default.

The DOM (Document Object Model) is a browser API, provided by the browser environment — not by JavaScript itself.

Node.js is a server-side runtime built on V8. It only includes the JavaScript engine and server-side APIs (fs, http, crypto, etc.), not browser APIs like document, window, or navigator.

There's no browser, no rendering engine, and no HTML page on the server — so there's nothing for a DOM to represent.

Interviewers ask this to check if you understand the difference between browser and server JavaScript environments. Mention the absence of window, document, and other browser APIs, and name alternatives like jsdom or cheerio if DOM manipulation is needed.

Can you access the DOM in Node.js? Why or why not? | Hiprup