Node.js Interview Questions

Key Node.js interview questions for backend and full-stack roles, covering the event loop, streams, error handling, and scaling — each with a concise answer. Then practice explaining them in a live mock.

Practice these live with an AI interviewer
Get asked questions one at a time and a scored feedback report — free.

10 common Node.js questions

What is Node.js and its execution model?

Node.js is a JavaScript runtime built on V8 for server-side code. It uses a single-threaded, non-blocking event loop with asynchronous I/O, so it handles many concurrent connections efficiently.

CommonJS require versus ES module import?

CommonJS is synchronous and uses module.exports/require; ES modules use import/export, are statically analyzable, and support top-level await. Node supports both — .mjs or "type":"module" selects ESM.

How does the Node event loop work?

It runs in phases (timers, pending callbacks, poll, check, close). Microtasks — promises and process.nextTick — run between phases, and blocking I/O is offloaded to libuv's thread pool.

Blocking versus non-blocking code?

Blocking code halts the event loop until it finishes (e.g. fs.readFileSync), starving other requests; non-blocking code uses callbacks or promises so the loop keeps serving work. Avoid blocking calls in request handlers.

What are streams?

Streams process data in chunks instead of loading it all into memory — Readable, Writable, Duplex, and Transform. They're ideal for large files or network data and are composed with .pipe().

How do you handle errors in async code?

Use try/catch with async/await, .catch() on promises, error-first callbacks, and 'error' events on streams and emitters. Always handle unhandled promise rejections so the process doesn't crash silently.

What is middleware in Express?

Middleware are functions with (req, res, next) that run in order to process a request — parsing bodies, auth, logging — calling next() to pass control or ending the response themselves.

process.nextTick versus setImmediate?

nextTick callbacks run right after the current operation, before the loop continues; setImmediate runs on the next iteration's check phase. Overusing nextTick can starve I/O.

How do you scale a Node app across CPU cores?

Node is single-threaded per process, so use the cluster module or worker_threads, or run multiple processes behind a load balancer (e.g. with PM2) to use all cores.

dependencies versus devDependencies?

dependencies are needed at runtime in production; devDependencies are only for development and builds (test runners, bundlers, linters). npm install --production skips devDependencies.

Ready to practice out loud?

Reading answers is one thing — saying them under pressure is another. Run a free AI mock interview and get scored feedback.

Start a mock interview

More interview questions