Interview questions

Node.js Interview Questions

20 Node.js interview questions with model answers: the event loop, nextTick vs setImmediate, streams, worker threads and Express. For both sides.

Node.js Interview Questions

What's here

20 Node.js interview questions, grouped into 4 areas: the runtime and the event loop, modules, async patterns and streams, building apis and production and scenarios. Each one comes with why it is worth asking and what a strong answer contains, so the same question can be scored the same way by different interviewers.

  • Ask candidates to predict the order of setTimeout, setImmediate, process.nextTick and promise callbacks in a short snippet, then discuss why.
  • Use the image-resizing scenario to test whether they connect event loop theory to design choices.
  • Ask about a production incident in a Node service and how they diagnosed it.
For hiring teams

Cohesyve finds, contacts and tests Node.js candidates on the real work, then ranks them for these interviews. 14-day free trial for 10 candidates, not charged until it ends.

Preparing for this interview yourself? Practise it free →

These Node.js interview questions cover what Node.js developer interviews test: how the event loop and libuv let a single JavaScript thread serve many connections, timers and process.nextTick, worker threads and clustering, modules, streams and error handling, building APIs with Express, and running Node in production. Candidates can use the 'what to look for' notes as model answers; interviewers can use them as a scoring guide.

The Runtime and the Event Loop

Node's concurrency model is the topic interviewers return to most.

  1. 1

    How can Node.js handle many concurrent connections with a single JavaScript thread?

    Why ask it

    The defining idea of Node.js.

    What to look for

    Node uses non-blocking I/O: operations are handed to the operating system kernel where possible, or to libuv's thread pool for some tasks, and their callbacks run on the event loop when results are ready. JavaScript stays on one thread, so CPU-heavy work blocks everything.
  2. 2

    Describe the phases of the Node.js event loop.

    Why ask it

    Separates real understanding from slogans about 'async'.

    What to look for

    Timers (setTimeout and setInterval callbacks), pending callbacks, idle/prepare (internal), poll (retrieve new I/O events and run I/O callbacks), check (setImmediate callbacks) and close callbacks. Each phase has a queue. Strong candidates note that the details changed in recent libuv versions, so exact ordering should not be over-relied on.
  3. 3

    What is the difference between process.nextTick, setImmediate and setTimeout(fn, 0)?

    Why ask it

    A classic Node-specific question.

    What to look for

    process.nextTick callbacks run right after the current operation, before the event loop continues, so recursive nextTick calls can starve I/O. setImmediate runs in the check phase of the next loop iteration. Inside an I/O callback, setImmediate always runs before a zero-delay timer. The Node docs recommend setImmediate in most cases.
  4. 4

    What blocks the event loop, and how would you detect it?

    Why ask it

    Event loop blocking is the most common Node performance problem.

    What to look for

    Synchronous file or crypto APIs, large JSON parsing or serialising, heavy loops, and inefficient regular expressions. Detect it by measuring event loop delay, profiling with the inspector or clinic-style tools, and watching latency rise across all endpoints at once.
  5. 5

    When would you use worker threads, child processes or the cluster module?

    Why ask it

    Tests the right tool for CPU and scaling problems.

    What to look for

    Worker threads suit CPU-intensive JavaScript and can share memory; they do not help much with I/O, which Node already handles efficiently, and creating them has overhead, so use a pool. Child processes run separate programs. Cluster runs several Node processes sharing a port to use multiple cores, though many teams scale with containers instead.
For hiring teams

Before the Node.js interviews, see who can do the work

Cohesyve finds and contacts Node.js candidates from your job description and tests each one on an AI job simulation of the role, so these questions go to a ranked shortlist. 14-day free trial for 10 candidates, not charged until it ends.

Modules, Async Patterns and Streams

Core APIs and patterns every Node developer uses.

  1. 6

    What is the difference between CommonJS and ES modules in Node.js?

    Why ask it

    Module format issues cause confusing errors.

    What to look for

    CommonJS uses require and module.exports and loads synchronously; ES modules use import and export, are statically analysable and support top-level await. Node chooses the format from the file extension or the package.json 'type' field. Mixing formats has rules, especially when requiring an ES module.
  2. 7

    What are streams, and what is backpressure?

    Why ask it

    Streams are how Node handles large data efficiently.

    What to look for

    Streams process data in chunks: readable, writable, duplex and transform. Backpressure is when a consumer cannot keep up, so the producer must pause; write() returning false signals it. stream.pipeline connects streams with proper error handling and cleanup, which manual piping often misses.
  3. 8

    How do you handle errors in asynchronous Node.js code?

    Why ask it

    Unhandled errors crash processes or leave them in a bad state.

    What to look for

    try/catch around await, .catch on promises, error-first callbacks in older APIs, and 'error' events on emitters and streams. Distinguish operational errors (timeouts, bad input) that should be handled from programmer errors where restarting the process is safer. Log unhandled rejections and exit cleanly.
  4. 9

    What is an EventEmitter, and where have you used it?

    Why ask it

    Many Node core APIs are built on it.

    What to look for

    An object that lets code register listeners for named events and emit them. Streams, HTTP servers and sockets all extend it. Good answers mention removing listeners to avoid leaks and that an unhandled 'error' event throws.
  5. 10

    What is a Buffer, and when do you need one?

    Why ask it

    Binary data comes up with files, network protocols and images.

    What to look for

    A Buffer holds raw binary data outside the normal string handling. You meet it when reading files without an encoding, handling network packets, hashing or working with images. Convert explicitly with an encoding such as utf8 or base64.

Building APIs

Most Node.js roles are about building and securing HTTP services.

  1. 11

    How does Express middleware work, and how is error-handling middleware different?

    Why ask it

    Express remains a common Node.js framework.

    What to look for

    Middleware functions take req, res and next and either end the request or call next(); forgetting both leaves the request hanging. Error-handling middleware takes four arguments (err, req, res, next) and is identified by that signature. Order of registration defines order of execution.
  2. 12

    How would you structure a Node.js API project?

    Why ask it

    Shows whether the candidate can build something maintainable.

    What to look for

    Separate routing, request validation, business logic and data access; configuration from environment variables; central error handling; logging; and tests at each layer. Avoid putting business logic in route handlers.
  3. 13

    JWTs or server-side sessions: how do you choose?

    Why ask it

    Authentication design has security consequences.

    What to look for

    Sessions store state on the server and are easy to revoke; JWTs are self-contained and suit stateless services but are hard to revoke before expiry. Either way: short lifetimes, secure and HttpOnly cookies where possible, validation of signature and claims, and refresh-token handling.
  4. 14

    How do you secure a Node.js application?

    Why ask it

    Node apps are exposed directly to the internet.

    What to look for

    Validate and sanitise all input, use parameterised queries, set security headers, rate-limit sensitive endpoints, keep secrets out of code, audit dependencies and lock versions, run as a non-root user, and keep the runtime on a supported release.
  5. 15

    How do you work with a database efficiently from Node.js?

    Why ask it

    Database access shapes performance.

    What to look for

    Connection pooling instead of a connection per request, parameterised queries, avoiding N+1 queries in ORMs, pagination, indexes for common queries, and timeouts. Strong answers mention transactions and handling pool exhaustion.

Production and Scenarios

Running Node services reliably, and realistic problems to reason through.

  1. 16

    Which Node.js version would you run in production, and why?

    Why ask it

    Release lines matter for security and support.

    What to look for

    An Active LTS or Maintenance LTS release, as the Node project recommends for production. Until Node 26, even-numbered majors became LTS; from Node 27 every major moves to LTS after its Current phase. LTS lines get critical fixes for around 30 months. Plan upgrades before end of life.
  2. 17

    How do you scale a Node.js service horizontally?

    Why ask it

    Single-process Node uses one core.

    What to look for

    Run several stateless instances behind a load balancer (containers, cluster or a process manager), move session and cache state to a shared store, and make background jobs safe to run on any instance. Good answers mention health checks and graceful shutdown.
  3. 18

    Memory usage keeps growing until the process restarts. How do you find the leak?

    Why ask it

    A common production problem.

    What to look for

    Reproduce under load, take heap snapshots over time with the inspector and compare what grows; common causes are unbounded caches, listeners never removed, closures holding large objects and global arrays. Fix, then confirm memory stabilises.
  4. 19

    How should a Node.js service shut down when it receives SIGTERM?

    Why ask it

    Ungraceful shutdowns drop requests during deploys.

    What to look for

    Stop accepting new connections, let in-flight requests finish within a timeout, close database pools and other resources, flush logs, then exit. Readiness checks should fail first so the load balancer stops sending traffic.
  5. 20

    An endpoint that resizes uploaded images makes the whole API slow. What do you do?

    Why ask it

    Ties event loop knowledge to a real design decision.

    What to look for

    Image processing is CPU-heavy and blocks the event loop for every request. Move it off the main thread with a worker pool, or better, to a background job queue with separate workers, returning a job ID or processing asynchronously. Stream uploads rather than buffering them in memory.

Running the interview well

  • 1Ask candidates to predict the order of setTimeout, setImmediate, process.nextTick and promise callbacks in a short snippet, then discuss why.
  • 2Use the image-resizing scenario to test whether they connect event loop theory to design choices.
  • 3Ask about a production incident in a Node service and how they diagnosed it.
  • 4Check JavaScript fundamentals (closures, promises, 'this') alongside Node-specific knowledge.
  • 5For senior roles, cover streams, memory leaks, graceful shutdown and scaling.
  • 6Let candidates use documentation for exact API signatures; score reasoning.

Common questions

What Node.js topics are asked most in interviews?

The event loop, non-blocking I/O, process.nextTick versus setImmediate, promises and async/await, modules, streams, error handling, Express middleware, worker threads and clustering.

How should I prepare for a Node.js developer interview?

Build an API with authentication, a database, validation and tests, then practise explaining the event loop and what blocks it. Read the official Node.js guide on the event loop, timers and process.nextTick, since many questions come from it.

Is Node.js single-threaded?

Your JavaScript runs on a single main thread by default, but Node uses the operating system and libuv's thread pool for I/O, and you can create worker threads for CPU-heavy work.

Do Node.js interviews include JavaScript questions?

Yes. Expect closures, 'this', promises, async/await and array methods, because Node.js code depends on them.

Do I need to know Express for a Node.js interview?

For most backend roles it helps a great deal, since many codebases use it or a similar framework. Know middleware, routing, error handling and validation. Other frameworks follow similar ideas.

What is libuv?

The C library that implements the Node.js event loop and its asynchronous behaviour, including a thread pool for some operations.

For hiring teams

Save these questions for the Node.js candidates who can do the work

Cohesyve takes your Node.js job description, finds candidates, reaches out to them and runs an AI job simulation of the real work, then returns a ranked shortlist.

1,500+

assessments completed

50%

faster time-to-hire

5 min

from JD to assessment

14-day free trial · 10 candidates · Not charged until the trial ends

For job seekers

Preparing for a Node.js interview yourself? Practise on an AI job simulation of the role. 3-day free trial, cancel anytime.

Practise a Node.js interview free →

See Cohesyve in action

Free 30-min walkthrough

See it on your role