Menu

What Is Node.js? The JavaScript Runtime Explained

Node.js is a runtime that runs JavaScript outside the browser, on servers and in the terminal. It is not a language and not a framework: it is V8 plus an event loop plus APIs for files, networks and processes.

This page includes runnable editors. Edit, run, and see output instantly.

Node.js is a runtime that runs JavaScript outside the browser: on a server, in a terminal, or as a command line tool. It is not a programming language (the language is JavaScript) and not a framework (Express is a framework that runs on Node.js). It combines Google's V8 engine, which executes JavaScript, with an event loop and built-in APIs for files, networking and processes that browsers do not have.

It printed the file's contents, the major version (v24), and undefined for window, because Node.js has no web page to give you one. fs and process exist only in Node.js; run the same lines in a browser tab and the first one throws.

Is Node.js a framework or a language?

Neither. JavaScript is the language. Node.js is the program that runs it, the same way the JVM runs Java or CPython runs Python. Frameworks sit on top: Express, Fastify and NestJS are libraries you install into a Node.js project. The Node.js vs JavaScript page compares the two in detail.

Under the hood, Node.js is four parts:

  • V8, the JavaScript engine from Chrome. It turns your code into machine code and runs it.
  • libuv, a C library that provides the event loop and does slow work (disk, network, timers) in the background, then hands the result back to your callbacks.
  • Node's own APIs: fs for files, http for servers, path, process, crypto, events and more, available with require or import and no install.
  • npm, the package manager that ships with Node.js and gives you access to the largest package registry of any language.

How to run a Node.js file

Install Node.js from its website (pick the LTS version), then check it from a terminal and run a file:

node --version     # prints v24.x.x or similar
node app.js        # runs app.js and exits when it has nothing left to do
node               # with no file: an interactive prompt (the REPL)

A program ends by itself once nothing is waiting: no timer, no open server, no pending file read. That is why a script exits but a web server keeps running.

Non-blocking I/O, the core idea

Node.js does not wait for slow work. It starts a file read or a network request, keeps running the next lines, and calls your function when the result is ready.

The two console.log lines after readFile ran first, and the file's contents arrived last. This is how one Node.js process serves thousands of connections: while one request waits for the database, the event loop keeps the others moving.

Node.js vs the browser

BrowserNode.js
RunsIn a web pageIn a terminal or on a server
Haswindow, document, the DOM, localStoragefs, process, http, Buffer, require
Global objectwindow (and globalThis)global (and globalThis)
Files on diskNo accessFull access, with your user's permissions
setTimeout, console, fetch, URLYesYes

What Node.js is used for

  • Web servers and APIs: REST and GraphQL backends, often with Express.
  • Real-time apps: chat, live dashboards and multiplayer games over WebSockets, where many connections stay open at once.
  • Command line tools: npm itself, Vite, ESLint, Prettier and TypeScript's compiler all run on Node.js.
  • Scripts and automation: renaming files, calling APIs, migrating data.

The most common use is an HTTP server, and the built-in http module is enough for a first one:

The server answered GET /hello with the path it received. Change the path in the request bar to /anything and send it: the reply follows, because this server handles every URL with one function.

When to choose Node.js

Choose Node.js when the work is mostly waiting on I/O (requests, databases, files) and you want one language on the frontend and backend. It is a weaker fit for long CPU-heavy calculations such as video encoding or large numeric work, because a long computation blocks the single JavaScript thread and every other request waits for it.

Frequently Asked Questions

Is Node.js frontend or backend?

Backend, mostly. Node.js runs on a server or your own machine, not in the visitor's browser. Frontend developers still use it every day, because tools like npm, Vite and ESLint are Node.js programs.

Who created Node.js and when?

Ryan Dahl released Node.js in 2009. It is now maintained by the OpenJS Foundation, with a new major version every six months and even-numbered versions getting long-term support.

Do I need to know JavaScript before Node.js?

Yes, the basics at least: variables, functions, objects, arrays, and callbacks or promises. Node.js adds APIs, not new syntax, so everything you learn about the language applies directly.

Is Node.js single-threaded?

Your JavaScript runs on one thread. Node.js uses a small thread pool behind the scenes for file system work, DNS and some crypto, so slow I/O does not block your code while it waits.

Coddy programming languages illustration

Learn to code with Coddy

Get started