Node.js Interview Questions 2026: 41 Questions With Answers
Node.js interview questions in 2026 cluster around five things: the event loop and libuv, async patterns plus error handling, streams and backpressure, scaling with cluster and worker threads, and backend security basics. The new-grad gap is explaining how the single-threaded runtime stays fast under load. This guide gives 45+ questions with answer outlines across the event loop, streams, middleware, EventEmitter, package management, and security, plus the prep plan that makes the answers stick.
By Sam K., Founder, InterviewChamp.AI · Last updated
31 min readTL;DR: Most Node.js interviews in 2026 come down to five clusters: the event loop, async patterns and error handling, streams and backpressure, cluster versus worker_threads, and backend security basics. None of them are syntax questions, because interviewers want to hear that you understand what the runtime does while your code waits. Below are 41 questions with answer outlines, a three-week prep plan, a breakdown by role and the mistakes that sink new grads.
What are the most common Node.js interview questions in 2026?#
Five topics show up in almost every loop. You'll be asked to explain the event loop and how Node stays fast on a single thread. You'll be asked how errors travel through callbacks, promises and async/await. Expect streams and backpressure, a comparison of the cluster module with worker_threads, and the security basics you'd apply to a public API. Those five clusters carry most loops.
The rest (EventEmitter, the module system, package management) is supporting material. It fills the gaps between the heavy hitters, and you'll usually get one or two questions from it, not a whole round.
Here's what catches new grads off guard: none of these are syntax questions. You can write an async function perfectly and still fail the round if you can't say what the runtime is doing while it waits. That's the whole game with Node interviews. The interviewer is checking whether you understand the runtime model, not whether you memorized an API.
How to use this question list#
The 41 questions are grouped by topic, starting with the most-tested:
- Event loop and libuv: Q1 to Q8
- Async patterns and error handling: Q9 to Q16
- Streams: Q17 to Q21
- Middleware and HTTP: Q22 to Q25
- Cluster and worker threads: Q26 to Q29
- EventEmitter, modules and package management: Q30 to Q35
- Backend security: Q36 to Q41
Each answer is an outline, not a script. Read it, close the page, and say the answer out loud in your own words. If you can't get through it without peeking, that's the question to drill again tomorrow. Interviewers can usually tell a memorized paragraph from a real explanation within a sentence or two, so the goal is understanding you can say on the spot.
Start with the first group even if you think you know it. The event loop questions decide more rounds than any other group.
What Node.js interviews test in 2026#
The short version: can you reason about an event-driven, non-blocking runtime well enough to predict how it behaves under load?
Node.js is a JavaScript runtime built on the V8 engine and the libuv C library. Almost every interview question traces back to one fact about it. Your JavaScript runs on a single main thread, so blocking that thread blocks every request the server is handling. The interviewer wants to know whether you can keep that thread free.
The 2025-2026 hiring cycle pushed backend roles toward sharper runtime questions than they used to ask. A few years ago, "what is Node" and "what is npm" were enough for an entry-level screen. As of 2026, even junior backend loops expect you to explain the event loop phases, spot code that blocks the loop, and name the right scaling primitive for a CPU-bound workload. The bar moved because the candidate pool got deeper and the easy questions stopped separating people.
Here's the rough mix of question types most new-grad candidates report seeing in their Node.js loops:
- 25-30% runtime internals (the event loop, libuv, the thread pool, blocking vs non-blocking)
- 20-25% async patterns and error handling (callbacks, promises, async/await, unhandled rejections)
- 10-15% streams and backpressure (piping, the four stream types, memory behavior)
- 10-15% scaling (cluster, worker threads, when to use which)
- 10-15% backend security and HTTP (input validation, injection, headers, auth basics)
- 5-10% module system and package management (CommonJS vs ESM, lockfiles, dependencies)
That first slice is the one that decides outcomes. A candidate who nails 15 surface questions but can't explain how one thread serves a thousand connections usually loses the round. Flip it around: a candidate who fumbles a package-management trivia question but draws the event loop cleanly usually advances. Put your prep time where the weight is.
Key terms#
Six terms come up so often that you should be able to define each one in a sentence.
Event loop: the mechanism that lets Node's single main thread handle many concurrent operations. It runs queued callbacks in ordered phases instead of blocking on each one.
libuv: the C library underneath Node. It implements the event loop plus a worker thread pool for the operations the OS can't do asynchronously, such as file system access and some cryptographic work.
Backpressure: the signal a slow Writable stream sends back to a fast Readable source to pause it, so data doesn't pile up in memory faster than it can be consumed.
EventEmitter: the base class behind Node's event model. Objects that extend it emit named events and run every listener registered for that name synchronously, in registration order.
Middleware: a function in a web framework's request pipeline. It receives the request, the response and a next callback, and it either handles the request or passes control to the next function in the chain.
Worker threads: real OS threads inside a single Node process. They can share memory and run JavaScript in parallel, and they're used to move CPU-bound work off the main thread.
Three more definitions are worth being able to say out loud, because they tend to come up as follow-ups.
Non-blocking I/O is the property that an I/O request (a database query, a network call, a file read) hands control back to your code right away and tells you about the result later through a callback, promise or event. The thread never sits waiting. That's the reason a single Node thread can have thousands of in-flight requests at once.
The microtask queue holds callbacks from resolved promises and from process.nextTick, and it drains completely between every event-loop phase. Because of that, a promise callback runs before the next setTimeout, and a runaway process.nextTick can starve I/O.
A Transform stream is a Duplex stream that changes data as it flows through: chunks come in, modified chunks go out. Compression, encryption and parsing are the classic examples. Naming one shows you understand streams beyond the textbook definition.
How to prepare for Node.js interview questions#
This is a focused three-week plan for a CS new grad who has shipped a tutorial CRUD app but has never explained the runtime under pressure. If you're further along, compress it. The six steps below match the structured plan that comes with this guide.
-
Master the event loop until you can draw it (week 1). Learn the phases in order: timers, pending callbacks, poll, check, close. Understand that libuv owns the loop and a worker thread pool (default size four) for file I/O and some crypto. Then write tiny scripts that log the order of
setTimeout,setImmediate,process.nextTickand an awaited promise, and predict the output before you run each one. If you can draw the loop on a whiteboard and explain why Node stays fast on one thread, you've cleared the single biggest filter. -
Drill async patterns and error handling (week 1, in parallel). Take one small program and write it three ways: callbacks with the error-first convention, raw promises, and async/await. Then practice the failure modes out loud. Cover an unhandled rejection, an error thrown inside a callback that an outer
try/catchnever sees, andPromise.allrejecting on the first failure whilePromise.allSettledwaits for everything. -
Build a real API server with a database (week 2). Three or four endpoints, a real database, input validation, structured error handling and a couple of tests. Add one route that streams a file so you can talk about streams from experience. Put it on GitHub with a README. That repo becomes the portfolio anchor that turns "no production experience" into a concrete story you can tell.
-
Learn streams, cluster and worker threads hands-on (weeks 2-3). Pipe a large file from a Readable to a Writable and explain backpressure as you go. Fork a server across your cores with the
clustermodule. Move a CPU-heavy function into a worker thread and measure how the loop stops stalling. Those hands-on minutes are what make your scaling answers sound real instead of recited. -
Drill backend security and the module system (week 3). Walk through the five security basics. Run an audit on your project's dependencies and read what one flagged vulnerability allows. Get clear on CommonJS
requireversus ES moduleimport, ondependenciesversusdevDependencies, and on why the lockfile makes builds reproducible. -
Run two timed mock interviews (end of week 3). Forty-five minutes each: one focused on runtime and async, one on backend design. Narrate your reasoning out loud the whole time. A peer, a paid mock service or an AI-driven tool all work. The first run exposes the gaps, and by the second you'll know exactly what to drill. If you're pricing the paid route, read this breakdown of mock-interview platforms staffed by working engineers, which sets them next to free peer swaps and AI tools, before you book a session.
Step one is the one you can't skip. Node interviewers can tell within two minutes whether you understand the event loop or just memorized the phase names, and there's no shortcut for that.
Event loop and libuv interview questions (8 Q)#
The event loop is the single most-tested Node concept, and it's the one most new grads get wrong. Learn the shape of each answer below, then say it in your own words.
Explain the Node.js event loop.
Show sample answerHide answerSay yours out loud first, then check.
Node runs your JavaScript on a single thread, and the event loop is what lets that thread juggle many concurrent operations without blocking on any one of them. When your code starts an async operation, like a file read or a network call, Node hands it to libuv and keeps going. When the operation finishes, its callback gets queued, and the event loop picks it up on a later pass. Each pass cycles through ordered phases and drains a queue of callbacks in each one. The point to say out loud: the loop only moves forward when the current callback finishes, so any long-running synchronous code freezes the entire server.
What are the phases of the event loop?
Show sample answerHide answerSay yours out loud first, then check.
There are six in order, counting an internal idle/prepare step you'll never touch, but the three you must know cold are timers, poll and check. Timers runs callbacks from setTimeout and setInterval whose time has passed. Pending callbacks runs certain deferred system callbacks. Poll fetches new I/O events and runs their callbacks, and it's where the loop spends most of its time. Check runs setImmediate callbacks. Close callbacks handles cleanup such as socket.on('close'). Between every phase, the microtask queue drains completely. What the interviewer is listening for is timers, poll and check named correctly, plus knowing that microtasks run between them. Reciting every phase flawlessly matters much less.
What is libuv and what does it do?
Show sample answerHide answerSay yours out loud first, then check.
libuv is the C library under Node that implements the event loop and a worker thread pool. The loop takes care of network I/O, which most operating systems can already do asynchronously at the kernel level. The thread pool (default size four) handles what the OS can't do async: file system access, DNS lookups through getaddrinfo, and some crypto functions like pbkdf2. The takeaway for the interview: when people say "Node is single-threaded," they mean your JavaScript runs on one thread. Behind the scenes, libuv quietly uses a small pool of background threads for the work that would otherwise block.
If Node is single-threaded, how does it handle thousands of concurrent requests?
Show sample answerHide answerSay yours out loud first, then check.
Because the thread almost never waits. A request triggers some I/O, say a database query or a call to another service, and Node starts it, registers a callback and moves straight on to the next request. The OS or the libuv thread pool does the waiting. Once the I/O completes, the callback is queued and the event loop runs it. One thread is enough as long as the work is mostly I/O-bound and nobody blocks the loop with synchronous CPU work. Name the limit out loud, too: this model breaks down for CPU-bound workloads, and that's where worker threads come in.
What does it mean to "block the event loop" and how do you avoid it?
Show sample answerHide answerSay yours out loud first, then check.
Blocking the loop means running synchronous code that takes a long time, so the loop can't advance to the next callback and every other request stalls behind it. The usual suspects are a readFileSync inside a request handler, JSON.parse on a huge payload, a synchronous crypto call or a tight CPU loop. To fix it, use the async versions of APIs, break big computations into smaller chunks that yield, and move genuinely CPU-bound work into a worker thread or a separate service. What interviewers want is for you to name blocking as the root cause of "the server gets slow under load."
What is the difference between process.nextTick and setImmediate?
Show sample answerHide answerSay yours out loud first, then check.
process.nextTick queues a callback to run right after the current operation completes, before the event loop moves to its next phase. setImmediate queues a callback for the check phase, which comes after poll. So if both are scheduled at the same moment, the process.nextTick callback runs first. The danger: the whole microtask queue, nextTick callbacks included, drains between phases, so a recursive process.nextTick can starve I/O and block the loop. The practical rule is to prefer setImmediate when you want to yield to I/O, and to save process.nextTick for the rare case where something must run before any I/O at all.
Where do promise callbacks run relative to the event loop phases?
Show sample answerHide answerSay yours out loud first, then check.
Resolved-promise callbacks, meaning the function you pass to .then or the code after an await, run on the microtask queue. That queue drains completely between every phase and after process.nextTick. It's why an awaited result gets processed before the next setTimeout fires, even a zero-delay timer. The classic interview trap is a snippet mixing setTimeout, setImmediate, process.nextTick and a resolved promise, where you have to call the print order. The rule: synchronous code first, then nextTick, then other microtasks (promises), then the macrotask phases.
setTimeout(() => console.log('timer fired'), 0);
setImmediate(() => console.log('check phase'));
Promise.resolve().then(() => console.log('microtask'));
process.nextTick(() => console.log('tick queue'));
console.log('main script');
// main script, tick queue, microtask, then timer fired and check phase
// (those last two can swap when run from the main module, see Q16)
What is the difference between blocking and non-blocking, synchronous and asynchronous, in Node?
Show sample answerHide answerSay yours out loud first, then check.
In practice, synchronous and blocking mean the same thing: the function runs to completion and the thread waits, so nothing else happens until it returns. Asynchronous and non-blocking mean the function starts the work, hands control back immediately, and delivers the result later through a callback, promise or event. Node's core APIs almost always offer both versions, for example fs.readFile (async, non-blocking) and fs.readFileSync (sync, blocking). For a server the rule is simple. Use the async form in any code path that handles requests, and keep the sync form for startup scripts where blocking does no harm.
Async patterns and error handling interview questions (8 Q)#
Async control flow is the second most-tested cluster. These questions cover callbacks, promises and async/await, plus the error-handling traps that sink candidates who are otherwise strong.
What is callback hell and how do you avoid it?
Show sample answerHide answerSay yours out loud first, then check.
Callback hell is deeply nested callbacks where each one depends on the result of the one before. The code drifts to the right and gets hard to read and even harder to error-handle. Promises fix it by flattening the nesting into a .then chain, and async/await goes further by letting asynchronous code read top to bottom like synchronous code. The interview point: async/await is syntactic sugar over promises, not a separate mechanism. An async function always returns a promise, and await just pauses the function until that promise settles.
What is a promise and what are its states?
Show sample answerHide answerSay yours out loud first, then check.
A promise is an object standing in for a value that may not exist yet. It has three states. Pending means the operation hasn't finished. Fulfilled means it succeeded, with a value. Rejected means it failed, with a reason. Once a promise settles to fulfilled or rejected, it never changes again. You consume it with .then for success, .catch for failure and .finally for cleanup, or with await inside an async function. The follow-up is usually about chaining: each .then returns a new promise, and that's how you sequence async steps.
What is the difference between Promise.all, Promise.race, and Promise.allSettled?
Show sample answerHide answerSay yours out loud first, then check.
Promise.all waits for every promise to fulfill but rejects the moment any single one rejects. That makes it the wrong pick when you want every result regardless of individual failures. Promise.allSettled waits for all of them and hands you an array saying which fulfilled and which rejected, and it never short-circuits. Promise.race settles as soon as the first promise settles, fulfilled or rejected, which is handy for timeouts. A typical scenario: you fetch from five services and one failure shouldn't kill the other four. That calls for allSettled, not all.
How do you handle errors with async/await?
Show sample answerHide answerSay yours out loud first, then check.
Wrap the awaited call in try/catch. Since await unwraps a rejected promise by throwing, a try/catch around it reads exactly like synchronous error handling. Two traps are worth mentioning. First, an async function that throws returns a rejected promise, so the caller has to await it or attach a .catch, or the rejection goes unhandled. Second, a try/catch can't catch an error thrown later inside a callback you passed to an async API, because that callback runs on a different tick, long after the try block exited.
async function loadUser(id) {
try {
const user = await db.findUser(id);
return user;
} catch (err) {
logger.error({ err, id }, 'user lookup failed');
throw err; // let the caller decide what the client sees
}
}
What is an unhandled promise rejection and why does it matter?
Show sample answerHide answerSay yours out loud first, then check.
It's what you get when a promise rejects and nothing handles it, with no .catch attached and no surrounding try/catch. In modern Node, an unhandled rejection terminates the process by default, because a silently swallowed error can leave the application in a corrupt state. You can watch for them globally through the unhandledRejection event on process. Treat that as a last-resort safety net and a place to log, though, not your main error strategy. The right fix is handling rejections where they happen.
What is the error-first callback convention?
Show sample answerHide answerSay yours out loud first, then check.
It's Node's classic callback pattern. An async function's callback gets the error as its first argument and the result as its second, like (err, data), and you check if (err) before touching data. The convention exists so callers deal with failures explicitly instead of relying on exceptions, which don't travel cleanly across async boundaries. Most modern code wraps these callback APIs in promises, through util.promisify or the fs/promises variants, so it can use async/await. Recognizing the convention still gets tested, because so much existing code is built on it.
How would you run several async operations in sequence versus in parallel?
Show sample answerHide answerSay yours out loud first, then check.
For sequence, await each one in turn, so the second starts only after the first resolves. Use that when each step needs the previous result. For parallel, start them all without awaiting, collect the promises and await Promise.all on the array, so they run concurrently and you wait once. Use that when the operations are independent. The classic new-grad mistake is awaiting independent operations one at a time inside a loop, which turns one round-trip of waiting into N round-trips. Say that trade-off explicitly and you signal real understanding.
// Sequential: each call waits for the one before it
for (const id of ids) {
results.push(await fetchOrder(id));
}
// Parallel: start everything, then wait once
const results = await Promise.all(ids.map((id) => fetchOrder(id)));
What is the difference between setTimeout(fn, 0) and setImmediate(fn)?
Show sample answerHide answerSay yours out loud first, then check.
Both defer a callback, but they target different phases. setImmediate runs its callback in the check phase, which follows poll. setTimeout(fn, 0) schedules a timer with a minimum delay (effectively a tiny floor) and runs in the timers phase. Called from the main module, their order isn't guaranteed, because it depends on timing. Called from inside an I/O callback, when the loop is already in the poll phase, setImmediate reliably runs first: check comes right after poll, while the timer has to wait for the next pass of the loop. That deterministic case is the one interviewers ask about.
Streams interview questions (5 Q)#
Streams are where backend-heavy loops start separating candidates. These questions cover the four stream types, piping and backpressure.
What are the four types of streams in Node?
Show sample answerHide answerSay yours out loud first, then check.
Readable streams are sources you read from, like a file read stream or an incoming HTTP request. Writable streams are destinations you write to, like a file write stream or an outgoing HTTP response. Duplex streams are both at once, a TCP socket being the usual example. Transform streams are Duplex streams that change the data as it passes through, such as a gzip compressor or a parser. Interviewers want a concrete example of each, and especially a Transform, since that's the one candidates forget.
How would you copy a large file without loading it all into memory?
Show sample answerHide answerSay yours out loud first, then check.
Open a Readable stream on the source and a Writable stream on the destination, then pipe one into the other so only small chunks sit in memory at any moment. pipeline from the stream module is the modern best practice. It wires up the data flow, handles backpressure, and cleans up and reports errors if any stream in the chain fails. Draw the contrast: reading the whole file into a buffer first works for a small file but exhausts memory on a multi-gigabyte one, and that's exactly the scenario the question is probing.
const fs = require('node:fs');
const { pipeline } = require('node:stream/promises');
async function copyFile() {
await pipeline(
fs.createReadStream('big-input.log'),
fs.createWriteStream('copy.log'),
);
}
copyFile().catch((err) => console.error('copy failed', err));
What is backpressure and how does Node handle it?
Show sample answerHide answerSay yours out loud first, then check.
Backpressure is what happens when a Readable produces data faster than a Writable can take it. Left alone, the unconsumed data buffers in memory until the process runs out. Node deals with it through the pipe mechanism. When the Writable's internal buffer fills, its write call returns false, the pipe pauses the Readable, and it resumes once the Writable drains. So if you pipe streams correctly, or use pipeline, backpressure is handled for you. Pull data manually and ignore the return value of write, and you've brought the memory problem right back.
What is the difference between flowing and paused mode for a Readable stream?
Show sample answerHide answerSay yours out loud first, then check.
In paused mode you pull data yourself by calling read(). In flowing mode, data is pushed at you as fast as it arrives through data events. A stream starts out paused and switches to flowing when you attach a data listener or call pipe. The practical risk: attaching a data listener starts the flow immediately, so if you aren't ready to consume, data can be lost or end up buffered. Piping is safer than handling data events by hand precisely because it manages the mode and the backpressure for you.
When would you write a custom Transform stream?
Show sample answerHide answerSay yours out loud first, then check.
Whenever you need to process a large stream chunk by chunk without buffering all of it. Think parsing a huge CSV line by line, compressing an upload on the fly, redacting fields from a log stream or converting formats during a copy. You implement the _transform method, which takes a chunk, does the work and pushes the result. Why reach for a Transform instead of buffering? It keeps memory flat no matter how big the input is, and that's the entire point of streams.
Middleware and HTTP interview questions (4 Q)#
Most Node web frameworks are built on a middleware model, and HTTP-layer questions show up in nearly every backend loop.
What is middleware in a Node web framework?
Show sample answerHide answerSay yours out loud first, then check.
Middleware is a function in the request-handling pipeline. It gets the request object, the response object and a next function. It can read or change the request and response, end the response, or call next to pass control down the chain. That's how frameworks compose cross-cutting concerns: logging, authentication, body parsing and error handling each become their own middleware function. The interview point is order. Middleware runs in the order you register it, so an auth middleware has to come before the route it protects.
How does error-handling middleware differ from regular middleware?
Show sample answerHide answerSay yours out loud first, then check.
Error-handling middleware takes four arguments instead of three: the error first, then request, response and next. The framework spots that four-argument signature and routes errors to it. You trigger it by passing an error to next(err) from any earlier middleware or route handler. Here's the trap that fails candidates. In older framework versions, throwing inside an async route handler doesn't automatically reach the error middleware, because the synchronous dispatcher never catches the rejected promise. You either await and call next(err) yourself, or use a wrapper that does it for you.
app.get('/orders/:id', async (req, res, next) => {
try {
res.json(await orders.find(req.params.id));
} catch (err) {
next(err); // hands the error to the four-argument handler
}
});
app.use((err, req, res, next) => {
res.status(500).json({ error: 'Something went wrong' });
});
What is the difference between req and res, and what is the request lifecycle?
Show sample answerHide answerSay yours out loud first, then check.
req is the incoming request: method, URL, headers, query parameters and body. res is the outgoing response you build: status code, headers and body. The lifecycle goes like this. The server receives the request, runs it through the middleware chain in order, a route handler produces a response, and res.end (or a helper like res.json) sends it. The rule to state is that you can send exactly one response per request. Calling a response method twice throws, and forgetting to send one leaves the client hanging until it times out.
How do you handle CORS in a Node API?
Show sample answerHide answerSay yours out loud first, then check.
CORS (Cross-Origin Resource Sharing) is the browser mechanism that decides which origins may call your API from client-side JavaScript. You configure it by setting response headers (the allowed origin, methods and headers) and by answering the browser's preflight OPTIONS request correctly. The security point interviewers want to hear: don't reflect every origin with a wildcard on an authenticated API, because that defeats the protection. Allow a specific list of trusted origins, and only turn on credentials for the ones you control.
Cluster and worker threads interview questions (4 Q)#
Scaling questions check whether you know how to use more than one CPU core, and which primitive fits which workload.
What is the cluster module and when do you use it?
Show sample answerHide answerSay yours out loud first, then check.
The cluster module lets you fork several Node processes (workers) that share one listening port, so incoming connections get spread across them and across your CPU cores. Each worker is a full Node process with its own event loop and its own memory. They coordinate by passing messages, not by sharing state. You reach for it to scale a network server past one core, since a single Node process tops out at one core for CPU. Worth adding: in production most teams run a process manager or a container orchestrator that does the same multi-process scaling, but the concept underneath is still cluster.
What are worker threads and how do they differ from cluster?
Show sample answerHide answerSay yours out loud first, then check.
worker_threads runs multiple threads inside a single process. Unlike cluster workers, they can share memory through SharedArrayBuffer and pass structured data cheaply. They exist for CPU-bound work like image processing, parsing or hashing, anything that would otherwise block the main thread's event loop. Here's the clean distinction to give. Cluster scales a server across cores by running many processes, while worker threads move heavy computation off the main thread within one process. One is for handling more connections; the other keeps CPU work from blocking the loop.
const { Worker } = require('node:worker_threads');
function hashInWorker(input) {
return new Promise((resolve, reject) => {
const worker = new Worker('./hash-worker.js', { workerData: input });
worker.once('message', resolve);
worker.once('error', reject);
});
}
When should you reach for worker threads instead of just async I/O?
Show sample answerHide answerSay yours out loud first, then check.
Async I/O solves I/O-bound problems, where the thread is mostly waiting on the network or disk. It does nothing for CPU-bound problems, where the thread is busy computing, because the computation still runs on the single main thread and blocks the loop. Once you have genuine CPU work (a large data transformation, synchronous crypto, video frame processing), async/await won't save you. You need a worker thread to run it in parallel on another core. Spotting that I/O-bound versus CPU-bound split is exactly the senior signal this question is fishing for.
Choosing the right Node scaling primitive by scenario.
Show sample answerHide answerSay yours out loud first, then check.
The trade-offs are easier to see side by side, so match the workload to the tool:
| Scenario | Bottleneck | Right primitive | Why |
|---|---|---|---|
| API server maxing out one CPU core under request load | Many connections, I/O-bound | cluster (or a process manager) | Spreads connections across cores; each worker runs its own loop |
| Resizing thousands of uploaded images | CPU-bound computation | worker_threads | Runs the heavy CPU work in parallel without blocking the main loop |
| Calling five slow downstream services per request | Waiting on network I/O | Promise.all (no extra threads) | The thread is idle while waiting; concurrency, not parallelism, is the fix |
| Hashing passwords on a busy auth endpoint | CPU-bound crypto | worker_threads or the async crypto API | Synchronous hashing blocks every request; offload it |
| Serving a 4 GB file download | Memory, not CPU | Streams (pipeline) | Streams chunks so memory stays flat regardless of file size |
Say the pattern out loud when you answer. Lots of I/O-bound connections point at cluster or plain async concurrency. CPU-bound work points at worker threads, and a large volume of data points at streams. The trap is picking the wrong one, like worker threads for an I/O problem or cluster for a CPU problem inside a single request.
EventEmitter, modules, and package management questions (6 Q)#
This group fills the gaps: Node's event model, how it loads code and how dependencies get managed.
What is an EventEmitter and how does it work?
Show sample answerHide answerSay yours out loud first, then check.
EventEmitter is the class behind Node's event-driven model. An object that extends it emits named events with emit('name', payload), and you register listeners with on('name', handler). Core objects like HTTP servers, streams and the process object are all EventEmitters. Three details get tested. Listeners run synchronously, in the order they were registered. There's a default soft limit of 10 listeners per event before Node warns about a possible leak. And emitting an error event with no listener throws and can crash the process, which is why long-lived emitters always get an error listener.
What is the difference between on and once?
Show sample answerHide answerSay yours out loud first, then check.
on registers a listener that fires every time the event is emitted. once registers one that fires the first time and then removes itself. You use once for one-shot events, like a connection's open or a stream's end, where reacting twice would be a bug or a leak. The usual follow-up is about memory. Forgetting to remove on listeners from objects that outlive their usefulness is a classic Node memory leak, and removeListener (or off) is how you clean them up.
What is the difference between CommonJS and ES modules in Node?
Show sample answerHide answerSay yours out loud first, then check.
CommonJS is Node's original module system. You export with module.exports and import with require, which loads synchronously and hands back the resolved value immediately. ES modules (ESM) use import and export, load asynchronously, support static analysis and tree-shaking, and are the JavaScript standard. The practical points for an interview: require is synchronous and can be called conditionally halfway down a file, while import is hoisted and static. A project signals ESM through the type field in package.json or an .mjs extension. Mixing the two takes care, because importing CommonJS from ESM and the other way round each has rules worth knowing.
What is the difference between dependencies and devDependencies?
Show sample answerHide answerSay yours out loud first, then check.
dependencies are the packages your application needs to run in production, like the web framework, the database driver or a validation library. devDependencies are only needed during development and build: test runners, linters, type definitions, bundlers. A production install skips devDependencies, which keeps the deployed artifact smaller and narrows the attack surface. Interviewers often probe the failure case too. Put a runtime dependency in devDependencies by mistake and you get a "works on my machine, crashes in production" bug, because the package exists locally but is missing from the production install.
What is the purpose of package-lock.json?
Show sample answerHide answerSay yours out loud first, then check.
The lockfile records the exact resolved version of every package in your tree, transitive dependencies included, so two installs from the same lockfile produce byte-identical node_modules. Without it, a caret range like ^1.2.0 could resolve to different patch versions on different machines or on different days, and that's how "it worked yesterday" bugs show up. Committing the lockfile is what makes builds reproducible across developers and CI. The thing to make clear is that the lockfile, not package.json, is the source of truth for what gets installed.
What is semantic versioning and how do version ranges work?
Show sample answerHide answerSay yours out loud first, then check.
Semantic versioning (semver) is the MAJOR.MINOR.PATCH scheme: major for breaking changes, minor for backward-compatible features, patch for backward-compatible fixes. In a dependency range, a caret like ^1.2.3 allows any version up to but not including the next major (so 1.x.x). A tilde like ~1.2.3 allows only patch updates (so 1.2.x). The risk worth naming: a caret range trusts every package to honor semver, and one dependency that ships a breaking change in a minor release can break your build. That's the practical argument for committing a lockfile.
Node.js backend security interview questions (6 Q)#
Security questions check whether you'd ship a public API without leaving it wide open. These are the ones that come up most.
What are the most important backend security practices for a Node API?
Show sample answerHide answerSay yours out loud first, then check.
Five carry most of the weight. First, validate and sanitize every input, because injection is still the top backend risk. Second, use parameterized queries or an ORM instead of building queries by string concatenation. Third, keep secrets in environment variables or a secrets manager, never in source. Fourth, set security headers and a tight CORS policy, and keep dependencies patched, since most real Node breaches arrive through a vulnerable transitive package. Fifth, hash passwords with a slow, salted algorithm and never log secrets or full tokens. The interview reward goes to explaining why each one matters, not just listing them.
How do you prevent injection attacks in Node?
Show sample answerHide answerSay yours out loud first, then check.
Never build a query or a shell command by gluing user input into a string. For databases, use parameterized queries, where the driver fills in placeholders safely, or an ORM that does it for you, so input stays data and never becomes executable query syntax. That applies to SQL and to NoSQL, where attacker-controlled objects can hijack query operators. For shell commands, avoid handing user input to a shell at all, and use an API that takes an argument array instead of a command string. The principle to state: keep the boundary between code and data intact.
// Unsafe: the input becomes part of the SQL text
db.query(`SELECT * FROM users WHERE email = '${email}'`);
// Safe: the driver sends the value separately from the query
db.query('SELECT * FROM users WHERE email = $1', [email]);
How should secrets and configuration be handled in a Node app?
Show sample answerHide answerSay yours out loud first, then check.
Secrets like database passwords, API keys and signing keys belong in environment variables or a dedicated secrets manager, loaded at runtime and never committed to the repository. Configuration that differs per environment works the same way, so one build runs in development and production with different values injected. The interview point: a secret committed to version control is compromised forever, even after you delete it, because it lives on in the history. The right response to a leaked secret is rotation, not just removal. And never log full secrets or tokens; redact them.
How do you handle authentication and sessions in a Node backend?
Show sample answerHide answerSay yours out loud first, then check.
There are two common models. Token-based auth issues a signed token at login that the client sends with every request, and the server checks the signature without storing any session state. Server-side sessions keep session data on the server (or in a shared store) and give the client an opaque session identifier in a cookie. The security details interviewers probe are concrete. Store tokens and session cookies with secure flags, HTTP-only so client script can't read them. Set sane expirations. Never put a secret or sensitive data in a token's payload, because anyone holding the token can read it.
Why do dependency vulnerabilities matter so much in Node, and how do you manage them?
Show sample answerHide answerSay yours out loud first, then check.
A typical Node project pulls in hundreds of transitive dependencies, and a vulnerability in any one of them is a vulnerability in your application. Most real-world Node breaches come through this supply chain, not through code the team wrote. You manage it by auditing dependencies regularly, patching or upgrading flagged packages promptly, committing a lockfile so you know exactly what's installed, and keeping the dependency count down where you can. The signal interviewers want is that you treat the dependency tree as part of your attack surface, not as someone else's problem.
How do you safely hash and store passwords in Node?
Show sample answerHide answerSay yours out loud first, then check.
Never store passwords in plain text, and never use a fast general-purpose hash. Use a slow, salted password-hashing algorithm built to resist brute force, so every guess costs an attacker real time. The salt, unique per password, blocks precomputed-table attacks. The slowness is the whole point: it barely affects one legitimate login but makes mass cracking expensive. At login, you hash the submitted password with the stored salt and compare. One detail worth adding is a constant-time comparison, so timing differences don't leak anything about the stored hash.
What a strong answer sounds like#
Across all 41 questions, the answers that land tend to share the same shape, and you can practice that shape directly.
- Lead with the one-sentence answer. "The event loop lets one thread handle many operations by running queued callbacks in phases." Then add detail.
- Name the limit or the trap. Strong answers almost always say where the idea breaks: CPU-bound work for the event loop,
Promise.allshort-circuiting, atry/catchthat can't see a later callback. - Tie it to something you built. "In my API I streamed a CSV export instead of buffering it" beats a definition every time, which is why step 3 of the plan matters so much.
- Say why, not just what. Listing "use parameterized queries" is fine. Explaining that it keeps input as data and never lets it become query syntax is what earns the point.
A weak answer usually does the opposite. It recites phase names in order, never mentions a trade-off and can't connect the idea to any code the candidate has written.
Node.js interview format by role type#
The same Node material gets tested differently depending on the role. Here's how it breaks down for the common Node-adjacent roles hiring new grads in 2026:
| Role | Runtime depth | Async depth | Streams | Scaling | Security focus | Domain extras |
|---|---|---|---|---|---|---|
| Backend Engineer (Node) | High | High | Medium-High | Medium | Medium-High | Databases, API design, system design |
| Full-Stack (Node + a frontend framework) | Medium | High | Low-Medium | Low | Medium | Frontend framework depth, API integration |
| Platform / Infra Engineer | High | Medium | High | High | High | Containers, observability, deployment |
| SDE with Node | Medium | Medium | Low | Low | Low-Medium | Algorithm rounds, system design, language depth |
Two patterns stand out. Every Node role tests the runtime floor, so the event loop and async control flow are universal. And streams, scaling and security weigh more heavily the closer a role sits to backend and platform work. A full-stack role leans on async plus the frontend framework, while a platform role leans hard on streams, scaling and security. Knowing which role you're targeting changes the prep mix more than most candidates realize.
Common Node.js interview mistakes for new grads#
These are the five most-reported mistakes from new-grad Node interviews in the 2025-2026 hiring cycle, roughly in order of how often they come up:
-
Calling Node "multithreaded" or fumbling the single-thread explanation. The whole runtime design hinges on one thread that offloads I/O and never blocks. Drill the event loop until you can explain, in your own words, how one thread serves thousands of connections. This is the question that ends rounds early.
-
Blocking the event loop and not recognizing it. A synchronous read, a giant
JSON.parseor a tight CPU loop in a request handler stalls every other request. Learn to name blocking as the cause of "slow under load," and know that worker threads are the answer for genuinely CPU-bound work. -
Treating async/await as magic and mishandling errors. People forget that an
asyncfunction returns a promise, that an unhandled rejection can crash the process, and that atry/catchcan't catch an error thrown later in a callback. Practice the failure modes out loud, not just the happy path. -
Buffering instead of streaming. Reading a whole file or response into memory when a stream would keep memory flat. Build one route that pipes a large file, and be ready to explain backpressure when asked.
-
Listing security practices without understanding them. Saying "input validation" and "use HTTPS" but not being able to explain injection, why secrets belong in environment variables, or why the dependency tree is part of the attack surface. Be able to say why each practice matters, because that's what interviewers grade.
One founder's note from watching new grads run Node rounds: don't try to cram all five fixes the night before. Pick the two that match your gaps (almost always the event-loop explanation and spotting a blocked loop) and close those first. If you want to rehearse these answers out loud and hear a model phrasing you can then put in your own words, run a mock Node round in the live interview assistant before the real one. That way you walk into your Node.js round able to say the answer instead of recognizing it after the fact.
Honestly, Node interviews for entry-level roles in 2026 reward candidates who understand the runtime model and have built at least one real backend. They're unforgiving to candidates who memorized API names without the mental model underneath. Years of experience aren't the differentiator. What matters is whether you can explain the event loop and recognize a blocked one. A live interview assistant you can start free (60 minutes a month with no card; Pro is $29 a month) gives you on-demand Node scenarios and a quiet answer outline to react to, so the rep cost of getting that fluency is a coffee instead of a friend's afternoon.
Related guides#
- System design basics for new grads: the framework for the backend design rounds that Node scaling and streams questions feed into.
- Python interview questions: the neighboring backend language, useful for contrasting the GIL with Node's event loop when an interviewer compares the two.
- AWS interview questions: where Node backends run in practice, covering the Lambda and architecture scenarios that pair with these runtime questions.
- Kubernetes interview questions: the orchestration layer that scales Node services across machines, picking up where the cluster module leaves off.
- Technical phone screen tactics: the round where Node runtime questions get asked under live observation.
About the author: Sam K. is the founder of InterviewChamp.AI, building AI interview prep for the new-grad CS market and writing about the modern interview gauntlet from the inside.
Originally published on InterviewChamp.AI
Related guides
Beyz AI Alternatives: 7 Tools Compared on Price
Beyz AI lists $49.99 a month, or $24.99 a month billed every 6 months. Lower or shorter-commitment alternatives include Verve AI at $16.99 a month as shown (billing period unclear), Cluely at $19.99 a month and InterviewChamp at $15 a week. Pick by billing period, free plan and refund terms, not by the per-month figure alone.
Sam K. ·
Read more →Cluely Alternatives: 7 Tools Compared on Price
The best Cluely alternative depends on what you need. Verve AI's card shows $16.99 a month, InterviewChamp Pro is $15 a week, and Sensei AI is $24 a month billed yearly. Cluely itself is free on Starter and $19.99 a month on its Pro card, so compare prices before you switch.
Sam K. ·
Read more →Final Round AI Alternatives: 7 Tools Compared on Price
Final Round AI's free plan has no live sessions, and Pro is listed from $25 a month. If you want to test live help before you pay, Verve AI, LockedIn AI and InterviewChamp each have a free start with no card. This page compares seven alternatives on price, free plans and refund rules.
Sam K. ·
Read more →Frequently asked questions
- What Node.js interview questions should I expect in 2026?
- Expect five clusters. Runtime internals (the event loop, libuv, the thread pool) make up roughly 25 to 30 percent of questions because they explain why Node stays fast on one thread. Async patterns and error handling are another 20 to 25 percent: callbacks versus promises versus async/await, and how errors propagate through each. Streams and backpressure run 10 to 15 percent. Scaling with cluster and worker threads is another 10 to 15 percent. Backend security basics and the module/package system fill the rest. Entry-level loops lean heavier on the event loop and async; backend-heavy loops add streams, scaling, and security.
- How do I explain the Node.js event loop in an interview?
- Start with the one-liner: Node runs your JavaScript on a single thread, and the event loop is what lets that single thread handle thousands of concurrent connections without blocking. Then name the phases in order: timers, pending callbacks, poll, check, and close callbacks. Explain that libuv (the C library underneath Node) owns the loop and a worker thread pool for operations the OS cannot do asynchronously, like file system calls and some crypto. Finish with the trap: `process.nextTick` and resolved promise callbacks run between phases on the microtask queue, before the next timer fires. Interviewers grade whether you understand why the loop exists, not whether you can recite all six phases perfectly.
- What is the difference between process.nextTick and setImmediate in Node.js?
- `process.nextTick` queues a callback to run immediately after the current operation finishes, before the event loop continues to its next phase. `setImmediate` queues a callback to run in the check phase, which comes after the poll phase. In practice, a `process.nextTick` callback runs before a `setImmediate` callback scheduled at the same time. The microtask queue (nextTick plus resolved promises) drains completely between every phase, which is why a recursive `process.nextTick` can starve the event loop and block I/O. The interview-safe rule: use `setImmediate` when you want to yield to I/O, and reach for `process.nextTick` only when you must run something before any I/O happens.
- How does error handling work with async/await versus callbacks in Node.js?
- Callbacks use the error-first convention: the first argument is the error, and you check it before using the result. Promises and async/await replace that with `try/catch` around the awaited call, which reads like synchronous error handling. The trap that fails candidates is the unhandled rejection: an async function that throws returns a rejected promise, and if nobody awaits or attaches a `.catch`, the rejection is unhandled. In modern Node that crashes the process by default. The other trap is forgetting that a synchronous `throw` inside a callback passed to an async API is not caught by an outer `try/catch`, because the callback runs later, on a different tick.
- What are streams in Node.js and why do they matter for interviews?
- Streams process data in chunks instead of loading it all into memory at once. Node has four types: Readable (a source), Writable (a destination), Duplex (both), and Transform (a Duplex that modifies data as it passes through, like compression). They matter because the canonical interview question is how you would copy a 4 GB file or stream a large HTTP response without exhausting memory: you pipe a Readable into a Writable so only small chunks live in memory at any moment. The senior follow-up is backpressure, which is the mechanism that pauses a fast source when a slow destination cannot keep up. Using `pipeline` from the `stream` module handles backpressure and error cleanup for you.
- What is the difference between cluster and worker threads in Node.js?
- The `cluster` module forks multiple Node processes that each run the full event loop and share a listening port, so incoming connections are spread across CPU cores. Each worker has its own memory; they communicate by message passing. `worker_threads` runs multiple threads inside one process that can share memory through `SharedArrayBuffer`, which makes them the right tool for CPU-bound work like parsing, image processing, or hashing. The decision rule for interviews: use cluster to scale a network server across cores, and use worker threads to move a CPU-heavy computation off the main thread so it stops blocking the event loop.
- What is an EventEmitter in Node.js?
- EventEmitter is the class behind Node's event-driven model. An object that extends it can emit named events with `emit('name', payload)` and register listeners with `on('name', handler)`. Core objects like HTTP servers, streams, and the process itself are EventEmitters. The interview-relevant details are three: listeners run synchronously in the order they were registered; the default limit is 10 listeners per event before Node warns about a possible memory leak; and an `error` event with no listener throws and can crash the process, which is why you always attach an error listener to long-lived emitters.
- What is the difference between dependencies and devDependencies in package.json?
- `dependencies` are packages your application needs to run in production, like a web framework or a database driver. `devDependencies` are packages needed only during development and build, like test runners, linters, and type definitions. When you run an install with the production flag set, devDependencies are skipped, which keeps the deployed image smaller and the attack surface narrower. The related interview point is the lockfile: `package-lock.json` pins the exact resolved version of every package and its transitive dependencies, so two installs produce identical trees. Committing the lockfile is what makes builds reproducible across machines and CI.
- What are the most important Node.js backend security basics for an interview?
- Five come up most. First, validate and sanitize every input, because injection (SQL, NoSQL, command) is still the top backend risk. Second, never build queries by string concatenation; use parameterized queries or an ORM. Third, store secrets in environment variables or a secrets manager, never in source or in the repo. Fourth, set security headers and a sane CORS policy, and keep dependencies patched because most real Node breaches come through a vulnerable transitive package. Fifth, hash passwords with a slow, salted algorithm and never log secrets or full tokens. Knowing why each matters, not just naming them, is what interviewers reward.
- Do Node.js interviewers expect production experience from CS new grads?
- No, but they expect you to have built at least one real backend, not just followed a tutorial. A REST API with a database, error handling, and a couple of endpoints under test is enough to make your answers credible. The honest framing that works: 'I built a small API server with a few endpoints, real validation, and tests, and here is what I learned about error handling and async control flow.' That turns 'no production experience' into 'has actually written Node.' Pretending you have run a high-traffic service you have not run gets you caught on the first scaling follow-up.
- What's the most common Node.js interview mistake new grads make?
- Saying Node is multithreaded, or being unable to explain how a single thread serves many concurrent requests. The whole runtime design hinges on the event loop offloading I/O to libuv and not blocking, so a candidate who cannot explain that fails the first real follow-up. The second most common mistake is blocking the event loop with synchronous work (a big JSON parse, a synchronous crypto call, a tight CPU loop) and not recognizing it as the cause of slow response times. Naming worker threads as the fix for CPU-bound work is the signal that separates the candidate who read about Node from the one who understands it.