QA
🟢
Backend

Node JS Interview Questions

Master Node.js runtime mechanics, non-blocking I/O, event emitters, child processes, buffer handling, and native C++ addons.

🎯 Ready to test your knowledge?

Take Node JS Skill Assessment Quiz

First prepare from the 100 learning questions below, then test your skills with 15 random MCQs categorized into Beginner, Intermediate, and Senior levels.

Launch 15-MCQ Quiz →
Experience Level:

Showing 100 Questions

Beginner LevelNode JS

1. How does the Node.js Event Loop work? Explain the 6 execution phases (Timers, Pending, Poll, Check, Close).

❓ Context: Explain libuv Event Loop phases, microtask queue priority (process.nextTick, Promises), and non-blocking I/O execution.

Node.js runs single-threaded JavaScript execution backed by libuv for asynchronous I/O. The Event Loop coordinates asynchronous callbacks across 6 distinct phases:

6 Event Loop Phases:

1
Timers: Executes callbacks scheduled by 'setTimeout()' and 'setInterval()'.
2
Pending Callbacks: Executes I/O callbacks deferred to the next loop iteration.
3
Idle, Prepare: Used internally by libuv.
4
Poll: Retrieves new I/O events (file reads, network sockets); executes I/O callbacks.
5
Check: Executes callbacks scheduled by 'setImmediate()'.
6
Close Callbacks: Executes close handlers (e.g. 'socket.on('close')').

Microtask Queue Priority:

'process.nextTick()' and resolved 'Promises' execute immediately after the current operation finishes, BEFORE the event loop advances to the next phase!

javascript
import fs from 'node:fs';

console.log('1. Script Start');

setTimeout(() => console.log('2. setTimeout (Timers Phase)'), 0);
setImmediate(() => console.log('3. setImmediate (Check Phase)'));

process.nextTick(() => console.log('4. process.nextTick (Microtask)'));
Promise.resolve().then(() => console.log('5. Promise.then (Microtask)'));

fs.readFile(__filename, () => {
  console.log('6. I/O Callback (Poll Phase)');
});

console.log('7. Script End');
💡Node.js Event Loop phase execution order demonstration.
🎯 Interview Key Takeaway

Microtasks (process.nextTick and Promises) execute immediately after the current operation completes, before the event loop advances phases.

#Node.js#Event Loop#libuv#Asynchronous#Beginner
Permalink
Beginner LevelNode JS

2. What does 'Single-Threaded, Event-Driven, Non-Blocking I/O' mean in Node.js?

Beginner LevelNode JS

3. What is the difference between process.nextTick() and setImmediate()?

Beginner LevelNode JS

4. Compare CommonJS (require/module.exports) vs ES Modules (import/export) in Node.js.

Beginner LevelNode JS

5. What is a Node.js Buffer and how do Buffer.alloc() and Buffer.from() handle raw binary data?

Beginner LevelNode JS

6. How does the EventEmitter class work in Node.js (on, emit, once, removeListener)?

Beginner LevelNode JS

7. What are the 4 fundamental types of Node.js Streams (Readable, Writable, Duplex, Transform)?

Beginner LevelNode JS

8. Compare synchronous (fs.readFileSync) vs asynchronous promise-based (fs.promises.readFile) file operations.

Beginner LevelNode JS

9. What is the Node.js global object and what built-in properties exist (process, __dirname, __filename, globalThis)?

Beginner LevelNode JS

10. How do you build a HTTP server using the native node:http module?

Beginner LevelNode JS

11. How do you handle uncaughtException and unhandledRejection events in Node.js?

Beginner LevelNode JS

12. What is the difference between path.join() and path.resolve() in node:path?

Beginner LevelNode JS

13. Compare child_process methods: exec, execFile, spawn, and fork.

Beginner LevelNode JS

14. What is the difference between dependencies, devDependencies, and peerDependencies in package.json?

Beginner LevelNode JS

15. How do you manage environment variables in Node.js (process.env and native --env-file)?

Beginner LevelNode JS

16. How does the native node:url module parse URLs using the WHATWG URL standard?

Beginner LevelNode JS

17. How do you generate cryptographic hashes and random tokens using node:crypto?

Beginner LevelNode JS

18. How do you inspect system hardware metrics using the node:os module?

Beginner LevelNode JS

19. How do you compress data streams using gzip and brotli in node:zlib?

Beginner LevelNode JS

20. How does util.promisify() convert error-first callback functions into Promises?

Beginner LevelNode JS

21. How do timers work in Node.js (setTimeout, setInterval, unref, ref)?

Beginner LevelNode JS

22. What advanced console debugging utilities exist in Node.js (time, timeEnd, trace, table)?

Beginner LevelNode JS

23. How do npm package.json scripts and lifecycle hooks (pre/post scripts) operate?

Beginner LevelNode JS

24. What is npx and how does it execute npm package binaries without global installation?

Beginner LevelNode JS

25. How does Semantic Versioning (SemVer: MAJOR.MINOR.PATCH) work in npm dependencies?

Beginner LevelNode JS

26. Why should you use string_decoder over Buffer.toString() for streaming multi-byte UTF-8 data?

Beginner LevelNode JS

27. Compare legacy node:querystring vs standard URLSearchParams.

Beginner LevelNode JS

28. How do you write zero-dependency assertions using the node:assert module?

Beginner LevelNode JS

29. How does the node:cluster module scale applications across multi-core CPUs?

Beginner LevelNode JS

30. How do you build interactive CLI prompts using the node:readline module?

Intermediate LevelNode JS

31. How does AsyncLocalStorage track request-scoped context across asynchronous call chains?

Intermediate LevelNode JS

32. Why should you use stream.pipeline() over stream.pipe() for streaming file transformations?

Intermediate LevelNode JS

33. How do Worker Threads (node:worker_threads) execute CPU-intensive tasks without blocking the main event loop?

Intermediate LevelNode JS

34. How does libuv thread pool sizing (UV_THREADPOOL_SIZE) impact async file I/O and crypto operations?

Intermediate LevelNode JS

35. How do you diagnose and fix Node.js memory leaks using heap snapshots and V8 metrics?

Intermediate LevelNode JS

36. How do you measure execution latency and HTTP metrics using the node:perf_hooks module?

Intermediate LevelNode JS

37. How do you configure HTTPS and TLS/SSL servers using node:https and node:tls?

Intermediate LevelNode JS

38. What are the core advantages of HTTP/2 in Node.js (node:http2) over HTTP/1.1?

Intermediate LevelNode JS

39. How do you build custom TCP servers and clients using the node:net module?

Intermediate LevelNode JS

40. How does the node:diagnostics_channel module enable decoupled APM tracing?

Intermediate LevelNode JS

41. How do you publish dual CJS/ESM npm packages using package.json "exports" and conditional exports?

Intermediate LevelNode JS

42. How does configuring http.Agent keep-alive connection pooling prevent TCP handshake latency under high load?

Intermediate LevelNode JS

43. How do you differentiate between operational runtime errors and fatal programmer bugs in Node.js architectures?

Intermediate LevelNode JS

44. Why is native fs.watch() unreliable across platforms and why do build tools rely on Chokidar?

Intermediate LevelNode JS

45. How do SharedArrayBuffer and Atomics prevent memory race conditions between multiple Worker Threads?

Intermediate LevelNode JS

46. How do you write unit and integration tests using the native node:test module and node:assert?

Intermediate LevelNode JS

47. How does tuning highWaterMark in stream constructors optimize buffer memory consumption?

Intermediate LevelNode JS

48. Why should you use scrypt or Argon2 over pbkdf2 for enterprise password hashing in Node.js?

Intermediate LevelNode JS

49. How do you interpret process.memoryUsage() metrics (rss, heapTotal, heapUsed, external, arrayBuffers)?

Intermediate LevelNode JS

50. How do you send and receive connectionless UDP datagram packets using the node:dgram module?

Intermediate LevelNode JS

51. How does the Node.js module resolution algorithm locate packages inside nested node_modules folders?

Intermediate LevelNode JS

52. What is a file descriptor (FD) leak and how do you ensure files are closed using fs.close() or file handles?

Intermediate LevelNode JS

53. How do you build domain-specific interactive CLI shells using the node:repl module?

Intermediate LevelNode JS

54. How does the node:v8 module serialize complex JS objects using v8.serialize() and v8.deserialize()?

Intermediate LevelNode JS

55. How do you process multi-gigabyte text files line-by-line without memory exhaustion using readline?

Intermediate LevelNode JS

56. How do you configure server.headersTimeout and server.requestTimeout to prevent Slowloris DDoS attacks?

Intermediate LevelNode JS

57. Why does EventEmitter throw "Possible EventEmitter memory leak detected. 11 listeners added" and how do you fix it?

Intermediate LevelNode JS

58. Why is child_process.execFile() safer and faster than child_process.exec() for running system binaries?

Intermediate LevelNode JS

59. How does the native global fetch API in Node.js 18+ replace axios and node-fetch?

Intermediate LevelNode JS

60. How do you handle SIGTERM signals in Kubernetes pods to drain connections before Node.js container termination?

Intermediate LevelNode JS

61. What is the difference between native Node.js Streams (node:stream) and standard WHATWG Web Streams (ReadableStream)?

Intermediate LevelNode JS

62. How do subpath imports (#utils/db) in package.json eliminate relative path hell (../../../../db)?

Intermediate LevelNode JS

63. How does process.hrtime.bigint() provide nanosecond-precision timing for performance benchmarking?

Intermediate LevelNode JS

64. How do you configure custom SSL/TLS certificate authorities (ca) for internal corporate microservice HTTPS requests?

Intermediate LevelNode JS

65. How do npm workspaces simplify multi-package monorepo dependency management and symlinking?

Intermediate LevelNode JS

66. How does the native node --watch flag in Node.js 18+ replace nodemon for automatic development process restarting?

Intermediate LevelNode JS

67. Why does Buffer.byteLength() differ from String.length for multi-byte Unicode strings?

Intermediate LevelNode JS

68. How do you configure socket.setKeepAlive() and socket.setTimeout() to detect dead TCP sockets?

Intermediate LevelNode JS

69. Why is v8.serialize() faster than JSON.stringify() for deep object cloning in Node.js?

Intermediate LevelNode JS

70. How do you build production health check endpoints using process.uptime() and memory metrics?

Senior LevelNode JS

71. How do V8 Hidden Classes (Shapes) and Inline Caching impact Node.js execution performance?

Senior LevelNode JS

72. How does V8 Garbage Collection work (Young Generation Scavenger vs Old Generation Mark-Sweep-Compact)?

Senior LevelNode JS

73. How do you measure and alert on Event Loop Lag in high-throughput Node.js microservices?

Senior LevelNode JS

74. How do Node.js Native Addons (N-API / Node-API) execute C++/Rust binaries directly?

Senior LevelNode JS

75. How do you implement Production Graceful Shutdown in Node.js applications for Kubernetes SIGTERM?

Senior LevelNode JS

76. How do Single Executable Applications (SEA) compile Node.js code into standalone binaries in Node 20+?

Senior LevelNode JS

77. How does the experimental Node.js Permission Model (--permission) sandbox file and process access?

Senior LevelNode JS

78. How do UNIX Domain Sockets achieve 40% lower latency than TCP loopback for IPC communication?

Senior LevelNode JS

79. How do you implement distributed OpenTelemetry tracing in Node.js microservices?

Senior LevelNode JS

80. What is the future trajectory of Node.js (Node 22+, native WebSocket client, require(ESM), node:sqlite)?

Senior LevelNode JS

81. How does libuv use kernel I/O multiplexing (epoll on Linux, kqueue on macOS, IOCP on Windows) for non-blocking sockets?

Senior LevelNode JS

82. How do you prevent Prototype Pollution and Remote Code Execution (RCE) in Node.js JSON parsing and object merging?

Senior LevelNode JS

83. When should you use native Node.js Cluster mode versus Kubernetes Horizontal Pod Autoscaling (HPA)?

Senior LevelNode JS

84. How do you debug production Node.js CPU spikes and kernel hangs using eBPF, Linux perf, and 0x flamegraphs?

Senior LevelNode JS

85. How do UNIX Domain Sockets achieve 100,000+ req/sec IPC microservice throughput?

Senior LevelNode JS

86. How do you write custom Node.js ESM loaders (--import hook) to transpile TypeScript or mock modules on the fly?

Senior LevelNode JS

87. How does internal Buffer pooling (Buffer.poolSize = 8192) work and what causes severe memory fragmentation?

Senior LevelNode JS

88. How does the native undici HTTP/1.1 and HTTP/2 client engine achieve 3x throughput over legacy http.request?

Senior LevelNode JS

89. How do you securely inject and rotate database credentials in Node.js using HashiCorp Vault without restarting processes?

Senior LevelNode JS

90. How do you implement enterprise Circuit Breaker patterns (opossum) in Node.js to survive downstream microservice outages?

Senior LevelNode JS

91. How do you scale 1,000,000 concurrent WebSocket connections across multiple Node.js servers using Redis Pub/Sub?

Senior LevelNode JS

92. How is Node.js preparing for Post-Quantum Cryptography (PQC) and migrating RSA/ECC to NIST standards?

Senior LevelNode JS

93. How do you implement distributed Token Bucket rate limiting in Node.js using atomic Redis Lua scripts?

Senior LevelNode JS

94. How do you defend Node.js APIs against Regular Expression Denial of Service (ReDoS) catastrophic backtracking attacks?

Senior LevelNode JS

95. How do you architect ultra-lean 50MB production Docker images for Node.js using multi-stage builds and distroless?

Senior LevelNode JS

96. How do you use native node:test mocking (t.mock) and coverage flags in Node 20+?

Senior LevelNode JS

97. How do you write a custom ESM loader hook to transpile TypeScript files in memory in Node 20+?

Senior LevelNode JS

98. How do you implement zero-downtime rolling worker reloads using the node:cluster module?

Senior LevelNode JS

99. How does V8 Code Caching (v8.compileFunction) accelerate Node.js application startup times?

Senior LevelNode JS

100. What is the future trajectory of Node.js (Node 22+, native WebSocket client, require(ESM), node:sqlite)?

How to Prepare for Node JS Technical Interviews in 2026

When interviewing for software engineering positions that utilize Node JS, hiring managers look for a combination of fundamental syntax proficiency, architectural understanding, code optimization techniques, and practical debugging skills.

🌱 Beginner FocusCore syntax, default configurations, standard API definitions, and avoiding common basic errors.
⚡ Intermediate FocusAsync execution patterns, performance profiling, component lifecycle, and state management.
🏆 Senior FocusInternal runtime mechanics, memory leaks, scalability bottlenecks, system design trade-offs, and security mitigation.