Interview Q&A · questions with model answers
Node.js Developer Interview Questions
Part of the study plan for: Full Stack Engineer
Ordered by how often they're asked. Most-asked answers are free to read in full; members see every answer and can rate their confidence on each.
-
Most asked What is Node.js and why is it well suited to I/O-heavy servers?
Node.js is a JavaScript runtime built on Chrome's V8 engine and libuv. It runs your JavaScript on a single main thread with an event loop and non-blocking I/O, so one process can handle many…
-
Most asked What are streams in Node.js and what is backpressure?
Streams process data in chunks instead of loading it all into memory. There are Readable, Writable, Duplex and Transform streams. Backpressure is the mechanism that slows a fast producer when a…
-
Most asked What are the differences between CommonJS and ES modules in Node.js?
CommonJS uses require/module.exports, loads synchronously and is evaluated at runtime; ES modules use import/export, are statically analyzable, load asynchronously, support top-level await, and are…
-
Most asked What does libuv's thread pool do, and which operations use it?
libuv maintains a thread pool (default 4 threads, configurable with UV_THREADPOOL_SIZE up to 1024) for operations that lack non-blocking OS APIs: most fs operations, dns.lookup, some crypto…
-
Most asked What are key security practices for Node.js web applications?
Validate all input (schemas), use parameterized queries, set security headers (helmet), apply rate limiting, keep dependencies patched (npm audit, Dependabot), avoid eval/child_process.exec with…
-
What is a `Buffer` in Node.js?
A Buffer is a fixed-length sequence of bytes (a subclass of Uint8Array) used for binary data: files, network packets, crypto output and encodings like UTF-8, base64 and hex.
-
What is the `EventEmitter` and where is it used?
EventEmitter implements the observer pattern: objects emit named events and listeners subscribe with on/once. Streams, HTTP servers, sockets and many libraries are EventEmitters.
-
What is prototype pollution and how do you prevent it?
Prototype pollution happens when attacker-controlled keys like proto, constructor or prototype are merged into objects (e.g., deep merge of JSON input), modifying Object.prototype so every object…
-
What is `AsyncLocalStorage` and how is it used?
AsyncLocalStorage (from node:async_hooks) stores data that follows an asynchronous execution flow, like thread-local storage for async code, so you can access request context (request ID, user,…
-
What are best practices for running Node.js in Docker?
Use an official slim/alpine Node LTS image, multi-stage builds, npm ci --omit=dev, copy package*.json first for layer caching, run as the non-root node user, set NODE_ENV=production, handle signals…
-
What is NoSQL injection in Node/MongoDB apps and how do you prevent it?
If request bodies are passed straight into queries, attackers can send operators instead of values, e.g. { "password": { "$ne": null } }, turning an equality check into 'any password'. Validate…
-
What is Node.js's permission model?
Started with --permission (experimental flag in Node 20, stable in later versions), Node restricts access to the file system, child processes, worker threads and native addons unless explicitly…
-
What are hidden classes and inline caches in V8, and why do they matter for performance?
V8 assigns objects 'hidden classes' (shapes) based on their property layout, and inline caches remember shapes seen at property access sites. Objects created with the same properties in the same…
-
What do `timer.unref()` and `ref()` do?
By default an active timer or handle keeps the process alive. unref() tells Node not to keep the event loop running just for that handle (e.g., a periodic metrics flush or a shutdown timeout), while…
-
What are dependencies, devDependencies and peerDependencies?
dependencies are needed at runtime, devDependencies only for development/build/test, and peerDependencies declare packages the host project must provide (e.g., a React component library peers on…
-
What is PM2 and is it still needed with containers?
PM2 is a process manager that keeps Node apps alive, restarts on crashes, runs cluster mode across cores, handles zero-downtime reloads and log management. In containerized platforms, the…
-
What is a circuit breaker and how would you use one in Node.js?
A circuit breaker (e.g., opossum) wraps calls to a dependency and, after repeated failures, 'opens' to fail fast for a cooldown period instead of piling up slow requests, then 'half-opens' to test…
-
What are best practices for using the `fs` module?
Prefer the promise API (fs/promises) or streams in servers; avoid synchronous methods (readFileSync) except at startup or in CLI scripts; stream large files; handle ENOENT and permission errors; and…
-
What does the Twelve-Factor App methodology recommend for Node services?
Config in environment variables, explicit dependencies (package.json + lockfile), stateless processes, backing services as attached resources, logs to stdout, disposability (fast startup, graceful…
-
What are Node.js Single Executable Applications (SEA)?
SEA lets you bundle a Node.js script (and assets) into the Node binary, producing one executable that runs without a separate Node installation, which is useful for distributing CLIs and tools.
-
What is `node:diagnostics_channel` used for?
It's a publish/subscribe API for diagnostic events: libraries (undici, http, and many frameworks) publish events on named channels, and APM/tracing tools subscribe without monkey-patching.
-
What is `node:sqlite`?
A built-in synchronous SQLite module (added in Node 22.5, initially experimental) providing DatabaseSync and prepared statements, which is useful for local tools, tests, caching and small embedded…
-
What is the Backend-for-Frontend (BFF) pattern and why is Node popular for it?
A BFF is a backend tailored to one frontend (web or mobile) that aggregates and reshapes data from multiple services, handles auth/session concerns, and reduces client round trips. Node fits well…
-
What are the options for running TypeScript in a Node.js backend?
Compile with tsc (or a bundler like esbuild/tsup) to JavaScript for production, use tsx or Node's built-in type stripping for development and scripts, and always run tsc --noEmit for type checking…