Node.js interview questions test the event loop, async patterns, Express and middleware, REST APIs, and the npm ecosystem. Backend interviewers use Node questions to check how you handle concurrency, errors, and I/O without blocking a single-threaded runtime. This page covers 40 real Node.js interview questions with answers across four formats: multiple choice, written answers, spoken responses, and live coding challenges, the same mix used in modern technical interviews.
Practice each question in your browser with no signup required. Answers stay hidden until you attempt the question: type, speak, or code your response first, then compare it against the model answer. Questions range from fundamentals for your first developer job to scenario-based questions for senior roles, so you can find the gaps in your knowledge before the real interview.
40 questions with answersLast updated: Oct 19, 2026
Choose a question. Pick any of the 40 questions. They mix multiple choice, written, spoken, and coding, the same mix a real interviewer uses.
Attempt your answer. Select a multiple-choice option, type your written response, record a spoken answer, or write code in the editor.
Reveal the model answer. Once you have attempted the question, the model answer unlocks so you can compare it with yours.
Move to the next question. Track how many questions you have attempted with the progress bar at the top of the page.
Take a mock interview. When you are ready, try a full mock technical interview on Plaicer with AI-driven follow-up questions.
Node.js Interview Questions and Answers
0 of 40 attempted
1Multiple choice
How would you describe Node.js and what problems does it solve for backend development?
Attempt the question first to reveal the answer.
Answer
Node.js enables writing backend code in JavaScript. Non-blocking I/O handles many concurrent connections efficiently. Single-threaded event loop with async operations scales better than traditional threaded models for I/O-bound tasks.
2Written answer
Describe Node.js purpose, how it runs JavaScript outside browsers, and its ecosystem
Attempt the question first to reveal the answer.
Answer
Node.js is a runtime built on Chrome's V8 JavaScript engine. Runs JavaScript server-side outside browsers. Single-threaded with non-blocking I/O. Perfect for I/O-bound applications like APIs and real-time apps. Ecosystem: Express for web framework, Socket.io for real-time communication, Mongoose for MongoDB, testing with Jest, build tools with Webpack. npm provides 2+ million packages. JavaScript everywhere: same language frontend and backend.
3Spoken answer
Walk through how you would build a simple REST API with Express
This browser cannot record audio. Answer the question out loud anyway, then compare yourself against the model answer below.
Attempt the question first to reveal the answer.
Answer
I created Express server with app.listen 3000. Defined routes: app.get api users callback returning users array. app.post api users callback reading request.body, validating, creating user, returning status 201. Used middleware: express.json parses JSON. Error handling: try-catch in routes, error middleware catches uncaught errors. This demonstrated REST principles with predictable HTTP methods and status codes.
4Coding
Create a basic Express server with a GET route returning JSON
Build your Node.js solution here
Attempt the question first to reveal the answer.
Answer
const express require express; const app express; app.get api hello (request, response) => { response.json { message Hello World } }; app.listen 3000, () => console.log Server running );
5Multiple choice
Explain the event loop and how it enables asynchronous operations
Attempt the question first to reveal the answer.
Answer
Event loop runs on single thread. Processes call stack first. Then microtasks (Promises). Then macrotasks (setTimeout, I/O). This allows non-blocking operations: async functions pause, returning control to event loop.
6Written answer
Explain how the event loop manages synchronous code, callbacks, and microtasks
Attempt the question first to reveal the answer.
Answer
Event loop runs on main thread. Phases: execute call stack synchronous code first, then process microtask queue Promises, then macrotask queue setTimeout, I/O, timers. Microtasks run before next macrotask. Understanding phases prevents timing bugs. Blocking operations block entire event loop. Non-blocking operations like file reads return control to event loop immediately.
7Spoken answer
Describe a situation where you debugged an event loop issue
This browser cannot record audio. Answer the question out loud anyway, then compare yourself against the model answer below.
Attempt the question first to reveal the answer.
Answer
Application was blocking event loop. Profiling showed long-running synchronous operation in request handler. Moved computation to worker thread or broke into smaller async chunks. Event loop now responsive to other requests. Learned: keep handlers short, offload heavy work, avoid blocking operations.
8Coding
Build a POST route that accepts JSON data and returns a response
Build your Node.js solution here
Attempt the question first to reveal the answer.
Answer
app.post api users (request, response) => { const user request.body; if not user.name return response.status 400 .json error; response.status 201 .json { id 1, ...user } };
9Multiple choice
Explain callbacks and how they handle asynchronous operations in Node.js
Attempt the question first to reveal the answer.
Answer
Callback function passed to async operation. Executed when operation completes. Error-first callbacks: callback error, result. Nested callbacks create callback hell. Promises and async/await are modern alternatives.
10Written answer
Explain callback-based asynchronous patterns and callback hell
Attempt the question first to reveal the answer.
Answer
Callbacks are functions executed when async operation completes. Node.js uses error-first callbacks: callback error, result. Reading files, database queries, network requests use callbacks. Nested callbacks creating pyramid structure: error handling becomes complex, code readability suffers. Callback hell demonstrates need for Promises and async/await. Modern code prefers Promises and async/await over callbacks.
11Spoken answer
Explain how you would migrate callback-based code to async/await
This browser cannot record audio. Answer the question out loud anyway, then compare yourself against the model answer below.
Attempt the question first to reveal the answer.
Answer
Legacy code had nested callbacks handling file reads and database queries. Converted to async/await: async function, await on operations, try/catch for errors. Code readability improved dramatically. Error handling centralized in try/catch. Sequential operations now look synchronous.
12Coding
Write an async function fetching data and handling errors with try/catch
Build your Node.js solution here
Attempt the question first to reveal the answer.
Answer
async function fetchData() { try { const data await fetch url .then res => res.json; return data; } catch error { console.error error; } }
13Multiple choice
Describe Promises and how they improve over callback-based asynchronous code
Attempt the question first to reveal the answer.
Answer
Promise represents eventual value or error. States: pending, resolved, rejected. .then handles success, .catch handles error. Chaining .then calls avoids callback nesting. Promise.all waits for multiple promises.
14Written answer
Describe Promise states, then/catch chains, and Promise.all
Attempt the question first to reveal the answer.
Answer
Promises have three states: pending initial, resolved success, rejected error. then handlers success, catch handlers error, finally runs regardless. Chaining thens allows sequential operations. Promise.all waits for all promises, returns array of results, rejects on first error. Promise.race returns first completed promise. Promise.allSettled returns all results with status.
15Spoken answer
Talk about handling errors in production Node.js applications
This browser cannot record audio. Answer the question out loud anyway, then compare yourself against the model answer below.
Attempt the question first to reveal the answer.
Answer
In production an unhandled error crashes the process, so I handle errors at three layers. Express error middleware catches route errors, logs them with request context, and returns a JSON 500 without the stack trace. Async handlers are wrapped so rejections forward to next(). At process level, process.on('uncaughtException') catches synchronous throws and process.on('unhandledRejection') catches promise rejections — two different events, and Node 15 and later crash on an unhandled rejection by default. Both handlers log and exit so the process manager restarts a clean instance. On SIGTERM I stop accepting connections, let in-flight requests finish, close the database pool, then exit. Monitoring alerts on error rate, not individual errors.
Explain async/await and how it simplifies asynchronous code flow
Attempt the question first to reveal the answer.
Answer
async function returns Promise. await pauses function, waits for Promise. Code reads synchronously. try/catch handles errors. More readable than .then chains. Still non-blocking internally.
18Written answer
Explain async/await syntax, try/catch error handling, and concurrency patterns
Attempt the question first to reveal the answer.
Answer
async keyword makes function return Promise. await pauses function waiting for Promise. Code reads synchronously, executes asynchronously. try block contains await, catch handles rejections. finally runs regardless. Multiple awaits execute sequentially. Using Promise.all awaits multiple promises concurrently. Proper error handling crucial for production reliability.
19Spoken answer
Describe implementing middleware for authentication
This browser cannot record audio. Answer the question out loud anyway, then compare yourself against the model answer below.
Attempt the question first to reveal the answer.
Answer
I created authentication middleware verifying tokens from headers. Middleware checked validity, rejected with 401 if invalid, added user info to request if valid. Applied middleware to protected routes: app.use path, authMiddleware, handler. This centralized auth logic, protected routes without duplication.
20Coding
Chain promises using then and catch
Build your Node.js solution here
Attempt the question first to reveal the answer.
Answer
fetch url .then response => response.json .then data => console.log data .catch error => console.error error ;
21Multiple choice
Describe npm and its role in Node.js package management
Attempt the question first to reveal the answer.
Answer
npm installs packages from npm registry. package.json lists dependencies. npm install fetches and installs. Semantic versioning: major.minor.patch. npm scripts automate tasks. Enables code reuse across projects.
22Written answer
Describe npm, package.json, dependencies, and version management
Attempt the question first to reveal the answer.
Answer
npm is Node.js package manager. package.json defines project metadata, scripts, dependencies, devDependencies. npm install reads package.json, downloads packages from npm registry, creates node_modules folder. Semantic versioning: major.minor.patch. Caret ^ allows minor updates, tilde ~ allows patch updates. package-lock.json locks exact versions for reproducible installs. npm scripts automate tasks like testing and building.
23Spoken answer
Explain how you would optimize database queries for performance
This browser cannot record audio. Answer the question out loud anyway, then compare yourself against the model answer below.
Attempt the question first to reveal the answer.
Answer
I profiled slow queries using database tools. Added indexes on frequently queried columns. Avoided N+1 queries: batch operations or join queries instead of looping. Used query caching for frequently accessed data. Selected only needed columns instead of wildcard. Result: queries 10x faster.
24Coding
Execute a database query using async/await
Build your Node.js solution here
Attempt the question first to reveal the answer.
Answer
async function getUser userId { try { const result await database.query SELECT * FROM users WHERE id = userId; return result.rows 0 ; } catch error { console.error error; } }
25Multiple choice
Explain middleware and how it processes requests in Express applications
Attempt the question first to reveal the answer.
Answer
Middleware: function receiving request, response, next. Executes code, modifies request/response, calls next() to continue chain. Order matters. Common: logging, authentication, parsing, error handling.
26Written answer
Explain middleware chains, request/response objects, and common middleware
Attempt the question first to reveal the answer.
Answer
Middleware functions execute in order. Signature: function middleware request, response, next. Receives request object properties, methods, response object methods for sending data. next() calls next middleware. Middleware can modify request/response. Common: express.json parses JSON, express.static serves files, cors handles cross-origin, authentication checks credentials. Error middleware has four parameters error, request, response, next.
27Spoken answer
Walk through creating a connection pool for database access
This browser cannot record audio. Answer the question out loud anyway, then compare yourself against the model answer below.
Attempt the question first to reveal the answer.
Answer
I created connection pool with pg-pool: new Pool connectionString, max 10 connections. Application requested connections, executed queries, released connections. Pool reused connections across requests. This reduced connection overhead. Configured pool size based on load testing.
Describe REST API principles and how to implement them with Express
Attempt the question first to reveal the answer.
Answer
REST: GET retrieve, POST create, PUT update, DELETE remove. Routes: app.get path, callback. Status codes: 200 success, 201 created, 404 not found, 500 error. Express handles routing and responses easily.
30Written answer
Describe REST principles, routing, status codes, and request/response handling
Attempt the question first to reveal the answer.
Answer
REST uses HTTP methods: GET retrieves, POST creates, PUT updates, DELETE removes. Routes define URLs and handlers. Express: app.get path, callback. Status codes: 200 OK, 201 Created, 400 Bad Request, 404 Not Found, 500 Server Error. Request body accessed via request.body after middleware parses. Response sent via response.json, response.send, or response.status. RESTful APIs are stateless, cacheable, and predictable.
31Spoken answer
Talk about managing async operations with Promise.all
This browser cannot record audio. Answer the question out loud anyway, then compare yourself against the model answer below.
Attempt the question first to reveal the answer.
Answer
API needed to fetch user, posts, and comments concurrently. I used Promise.all userId, postId => Promise.all fetchUser, fetchPosts, fetchComments. All requests ran in parallel. Result returned array with all data. Much faster than sequential awaits.
Explain database connections and connection pooling for performance
Attempt the question first to reveal the answer.
Answer
Creating connections is expensive. Connection pool maintains ready-to-use connections. Reusing connections reduces overhead. Pool size affects throughput and resource usage. Configure based on application load.
34Written answer
Explain connection pooling, query execution, and transaction management
Attempt the question first to reveal the answer.
Answer
Database connections are expensive to create. Connection pool maintains ready connections. Applications request from pool, release after use. Pool size affects performance: too small causes waiting, too large wastes resources. Query execution: send SQL or operations to database, receive results. Transactions: group operations, commit all or rollback all. Connection pooling libraries: pg-pool for PostgreSQL, mysql2 for MySQL.
35Spoken answer
Describe testing Node.js API endpoints
This browser cannot record audio. Answer the question out loud anyway, then compare yourself against the model answer below.
Attempt the question first to reveal the answer.
Answer
I used Jest and supertest to test API. Test created request: request app .get api users .expect 200. Mocked database. Verified response structure. Tested error cases: missing fields, invalid input, 404 responses. Continuous integration ran tests on push. 100% coverage on critical paths.
36Coding
Fetch data from external API using node-fetch or axios
Describe error handling patterns and best practices in Node.js applications
Attempt the question first to reveal the answer.
Answer
try/catch wraps async/await. Error middleware in Express: (error, request, response, next) signature. Unhandled errors crash application. Proper handling: log, respond with status code, continue gracefully.
38Written answer
Describe try/catch, error middleware, logging, and graceful error responses
Attempt the question first to reveal the answer.
Answer
try block wraps potentially throwing code. catch block handles exceptions. Error object contains message and stack trace. Error middleware in Express: app.use error, request, response, next signature. Middleware runs if error thrown or passed to next. Logging: save error details for debugging, different levels: info, warn, error. Graceful responses: return status code and error message without crashing application.
39Spoken answer
Explain how you would deploy a Node.js application to production
This browser cannot record audio. Answer the question out loud anyway, then compare yourself against the model answer below.
Attempt the question first to reveal the answer.
Answer
I built Docker image with Node.js runtime, packaged application. Pushed image to registry. Deployed to cloud platform: AWS ECS, Google Cloud Run, or Heroku. Environment variables configured per deployment. Monitoring with application performance monitoring tools. Logs aggregated to central service. Graceful shutdown handled in process.on SIGTERM.
40Coding
Create database connection pool for reuse
Build your Node.js solution here
Attempt the question first to reveal the answer.
Answer
const Pool require pg .Pool; const pool new Pool max 10 idleTimeoutMillis 30000 ; pool.query SELECT * FROM users (error, result) => result.rows ;
Topics covered
Node.js fundamentals: the runtime and its backend role
The event loop: phases, microtasks, avoiding blocking
Databases: queries with async/await, connection pooling, transactions
File system: reading and writing files with fs.promises
The npm ecosystem: package.json, semver, lockfiles
Testing and deployment of Node APIs
Frequently asked questions
How many Node.js interview questions are on this page?
40 real Node.js interview questions across four formats: multiple choice (10), written answer (10), spoken answer (10), and coding (10).
Do I need to sign up to practice?
No. All 40 questions and model answers are free with no signup. You attempt each question first, and the model answer unlocks once you have engaged.
Who are these Node.js interview questions for?
Developers preparing for Node.js technical interviews at any level, from first job to senior engineer roles. Questions cover fundamentals through real-world scenarios.
What topics do the Node.js questions cover?
The questions cover the Node.js runtime, the event loop, and async patterns. They also test Express routing, middleware, and REST principles. Other topics include error handling, database connection pooling, the file system, and npm.
Can I practice coding questions in the browser?
Yes. Coding questions include starter code in an in-browser editor, so you can write your solution without installing anything.
How often are the questions updated?
The question bank is reviewed regularly and updated to reflect current Node.js interview patterns.
Can I take a full mock interview?
Yes. Plaicer's mock technical interview walks you through a realistic 30 to 45 minute interview with AI-driven follow-up questions.
Do I need to know Express for Node.js interviews?
It helps. Many backend interviews assume Express for routing and middleware, so these questions cover it alongside core Node concepts like the event loop and async patterns.