Stop 11 · Backend with Node.js & ExpressTopics · 2/9

Node.js Runtime

Part of the Web Development Roadmap

In short

JavaScript once lived only inside browsers. Node.js let it out, with access to files, networks and processes, so you can build a whole backend in a language you already know.

Node.js runs JavaScript outside the browser, on your computer or a server, so you can build backends and tools with the same language you use for the frontend.

The mascot cook stands in a fully equipped dhaba kitchen holding a ladle.

Think of it like this

From home kitchen to a full dhaba

At home, the cook can only use what the house allows. Node.js gives the same cook a full dhaba kitchen: gas, water, a delivery window, a phone line. The cooking skill (JavaScript) stays the same, the tools around it grow.

Watch it happen

What's inside Node.js

Node.js
V8 engine
libuv
Core modules
node:fs
node:http
npm (bundled)

1/5Node.js is a program you install. Run node app.js and it executes your JavaScript outside any browser.

The big ideas

What you need to know

No browser, no DOM

There's no window, document or localStorage in Node. Instead you get process, fs, Buffer and network modules.

One thread for your JS

Your JavaScript runs on a single main thread. Slow work like disk and network happens in the background.

Web APIs where they fit

Modern Node includes fetch, URL, setTimeout and crypto.randomUUID, so much browser knowledge carries over.

Use an LTS version

Even-numbered releases become Long Term Support and get fixes for years. Run those on servers.

See it in code

Walk through the code

js
1// info.mjs  (run: node info.mjs)2import os from "node:os";3import { readFile } from "node:fs/promises";4 5console.log("Node version:", process.version);6console.log("Platform:", process.platform, os.arch());7console.log("CPU cores:", os.availableParallelism());8 9const me = await readFile(new URL(import.meta.url), "utf8");10console.log("This file has", me.split("\n").length, "lines");11 12console.log(typeof window); // "undefined": no browser here

1/4Core modules are imported with the node: prefix.

Top-level await works because .mjs files are ES modules. Everything used here comes built into Node, so there's nothing to npm install.

Save yourself the pain

Common mistakes

Oops

Using window, document or localStorage in Node code.

Do this instead

Node has no page. Use process, fs and environment variables instead, and keep browser-only code in the frontend.

Oops

Running an odd-numbered 'Current' release in production.

Do this instead

Pick an Active LTS release for servers. It gets security fixes for much longer.

Your mission

Meet your runtime

~10 min

Quick check

Which of these exists in Node.js but not in a normal browser tab?

Go deeper

  1. 1Install the LTS version of Node.js and run a hello.js file with node hello.js.
  2. 2Notice that browser objects like window and document don't exist in Node.
  3. 3Read a file from disk using the built-in fs module.

Also part of these roadmaps

More topics at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge