99 questions in 9 topics
Node.js Basics Interview Questions
What a first backend round checks: what Node.js is, non-blocking I/O, npm and the built-in globals.
- What is Node.js?
- What is the REPL in Node.js?
- Is Node.js single-threaded?
- What is the difference between JavaScript in Node.js and in the browser?
Node.js Event Loop and Async Interview Questions
How Node.js runs timers, I/O callbacks and promises on one thread, and the ordering questions built on that.
- Explain the Node.js event loop and its phases.
- In what order do
setTimeout(0),queueMicrotaskandPromise.thenrun? - What is the difference between
process.nextTick,setImmediateandsetTimeout(fn, 0)? - Does
setTimeout(fn, 0)orsetImmediaterun first?
Node.js Modules Interview Questions
How require and import find, load and cache code, and where the two systems differ.
- What is the difference between CommonJS and ES modules in Node.js?
- What happens when you reassign
exportsinstead ofmodule.exports? - How does
requirework, and where doexports,requireand__dirnamecome from? - Are Node.js modules cached? What does that mean for singletons?
Node.js Streams and Buffers Interview Questions
Buffers for binary data, streams for data that does not fit in memory, and backpressure.
- What is a Buffer in Node.js?
- Is a string's
lengththe same as its byte length in Node? - What happens when you pass 256, -1 or 3.9 to
Buffer.from? - Does writing to a
subarraychange the original buffer?
Express.js Interview Questions
Express examples are static because this page has no npm packages; the last question uses http and runs.
- What is Express.js, and why use it instead of the
httpmodule? - What is middleware in Express?
- What is the difference between
req.params,req.queryandreq.body? - How do you handle errors in Express?
Node.js Error Handling Interview Questions
Where an error goes in callbacks, promises, emitters and the process, and what a service should do with it.
- Can
try/catchcatch an error from an asynchronous callback? - How do you handle errors with async/await in Node.js?
- Is
returnthe same asreturn awaitinsidetry/catch? - What happens to an unhandled promise rejection in Node.js?
Node.js Performance and Scaling Interview Questions
Using every CPU core and keeping CPU-heavy work off the event loop.
- What is the
clustermodule and how does it work? - What are worker threads in Node.js, and when do you use them?
- What is the difference between
cluster,worker_threadsandchild_process? - What is the difference between
spawn,exec,execFileandfork?
Advanced Node.js Interview Questions
Production behavior and design: shutdown, request context, leaks, security, testing and scaling out.
- How do you shut down a Node.js server gracefully?
- What is
AsyncLocalStorageand what problem does it solve? - How do you find and fix a memory leak in Node.js?
- What are the most common security issues in Node.js applications?
Node.js Coding Interview Questions
Small utilities and log processing problems from Node.js rounds; every solution runs here.
- Implement a simple
EventEmitterwithon,off,onceandemit. - Write your own
promisify. - Run async tasks with at most N in flight at once (a promise pool).
- Write a function that retries a failing async call with exponential backoff.
Frequently Asked Questions
How do I prepare for a Node.js interview?
Start with the event loop, because most answers lean on it: the phases, process.nextTick versus promises versus timers, and why blocking code hurts. Then cover modules, streams, error handling and Express. Build one small API with validation, a database and error middleware, and finish with a few coding problems in JavaScript, solved out loud.
What Node.js questions are asked to freshers and to experienced developers?
Freshers get definitions with a short example: what Node.js is, blocking versus non-blocking, npm, module.exports, promises and basic Express. With 3 to 5 years, expect the event loop in detail, streams and backpressure, and error handling. Senior rounds ask about production: scaling, memory leaks, graceful shutdown, security and design trade-offs.
Do I need to know Express for a Node.js interview?
Usually yes. Most Node.js jobs use Express or a framework with the same ideas (Fastify, NestJS, Koa), so expect questions on middleware, routing and error handling. Knowing the built-in http module lets you explain what the framework does for you.
Are DSA and coding problems part of Node.js interviews?
Often, especially at product companies and in campus placements: one or two array, string or hash map problems solved in JavaScript. Node.js rounds add practical tasks such as a promise pool, a retry helper or processing a log file with streams. The problems linked on this page cover the common patterns.
How long does it take to prepare for a Node.js interview?
If you already write JavaScript, two to three weeks: one on the core questions and the event loop, one on streams, errors and Express with a small project, and the rest on coding problems and mock interviews. Coming from another language, learn closures, this, promises and async/await first.