Full answer
Node.js is not a language or a framework. It is a runtime: a program that embeds the V8 JavaScript engine (the same engine as Chrome) and adds things a browser does not have, such as file access, TCP sockets and child processes. Those extra abilities come from libuv, a C library that talks to the operating system.
Your JavaScript code runs on one thread, the main thread. Only one piece of JavaScript executes at any moment, so two callbacks never change the same variable at the same time. That removes most locking problems.
Waiting is different. When you ask for a file or a network response, Node gives the job to the operating system or to libuv's thread pool (4 threads by default) and carries on. When the job finishes, its callback is queued, and the event loop runs it on the main thread when the thread is free. Think of a canteen with one cashier (the main thread) and a kitchen with several cooks (the OS and thread pool). The cashier never cooks, so the queue keeps moving.
So "single-threaded" is true for your JavaScript and misleading for the whole process. A running Node process has several threads: V8 helper threads for garbage collection, the libuv pool, and any worker_threads you start yourself. The real limit is that a long calculation on the main thread blocks every other request.
const fs = require('node:fs');
const { isMainThread, threadId } = require('node:worker_threads');
console.log('1. start, main thread:', isMainThread, 'threadId:', threadId);
fs.readFile(__filename, () => {
// The read happened in the background, but this callback runs on the main thread.
console.log('3. readFile callback, main thread:', isMainThread, 'threadId:', threadId);
});
console.log('2. end of script (the read has not been reported yet)');The file read is done by libuv in the background, but the callback still runs on the JavaScript thread. Save it as app.js and run it with node app.js. Output (Node.js v24.22.1, same on two runs): 1. start, main thread: true threadId: 0 2. end of script (the read has not been reported yet) 3. readFile callback, main thread: true threadId: 0
Key points
- Your JavaScript runs on one main thread, one callback at a time.
- V8 runs the JavaScript. libuv provides the event loop, the thread pool and the OS calls.
- I/O waits do not occupy the main thread, so one thread can serve many connections.
- CPU-heavy JavaScript blocks everything, so it must be split up or moved to worker threads.
Common mistakes
- Saying Node.js is a language or a framework.
- Believing that a Node process has exactly one thread in total.
- Thinking async code runs in parallel on several JavaScript threads. Callbacks are interleaved, not simultaneous.
- Using Node for heavy CPU work in the request path without worker threads.
Follow-ups
- Which Node.js operations use the libuv thread pool and which do not?
- How does Node handle 10,000 open connections with one JavaScript thread?
- What would you change if one endpoint needs 200 ms of pure CPU work per request?
Tips
- Describe Node as V8 plus libuv in one sentence, then explain what runs where.
- Use the cashier and kitchen picture only if it helps. Interviewers care more about the blocking consequence.
- Mention worker_threads early when the question moves to CPU-bound work.