Skip to content
tezvyn:

Nodejs

179 bites tagged Nodejs — interview questions with model answers, and 60-second explainers.

Node.js & Express1 min read

fs.readFileSync vs fs.readFile

Sync blocks the event loop and returns directly, async takes a callback or promise, only sync is safe at startup. grasp of blocking vs non-blocking I/O. using readFileSync inside a request handler.

Node.js & Express1 min read

Async iterators and for await...of for streaming

Async iterators yield values lazily over time; for await...of consumes them sequentially with backpressure, keeping memory bounded. streaming vs buffering everything.

Node.js & Express2 min read

Bounded concurrency for many async requests

Chunk the array and await Promise.all per chunk, or run a fixed worker pool pulling from a shared index; cap in-flight requests. limiting concurrency, not just running parallel. firing all 1000 at once or going fully serial.

Node.js & Express1 min read

Handling async errors in Express middleware

Await inside try/catch and call next(err) on failure, or wrap the handler in an async error adapter; never let a rejected Promise go uncaught. routing async errors into Express.

Node.js & Express1 min read

The three states of a JavaScript Promise

Pending, fulfilled, rejected; settle is one-way and final; create with the executor calling resolve or reject, consume with then and catch. fundamentals of Promise lifecycle.

Node.js & Express1 min read

Monorepo workspaces vs private npm packages

Workspaces give atomic cross-service changes and instant local linking but couple release cadence; private packages give versioned isolation but add publish overhead and version drift. tradeoffs of code-sharing strategies.

Node.js & Express1 min read

Diamond dependencies and nested node_modules

Npm hoists one version to the top and nests the conflicting version under the dependent package; both coexist on disk. understanding npm's nested install layout.

Node.js & Express1 min read

Circular dependencies in CommonJS modules

When A requires B which requires A, the cache returns A's partial exports; fields defined later are undefined at that moment. deep understanding of CommonJS loading.

Node.js & Express1 min read

SemVer and the caret vs tilde range operators

MAJOR.MINOR.PATCH signals breaking/feature/fix; caret allows minor and patch updates, tilde allows only patch; use tilde for tighter control. understanding version ranges.

Node.js & Express1 min read

Layered structure for a scalable Express API

Routes map URLs, controllers handle HTTP, services hold business logic, data layer talks to the DB; keep each layer ignorant of HTTP except controllers. separation of concerns and testability.

Node.js & Express1 min read

Choosing between CommonJS and ES Modules

ESM is the standard with static import/export and top-level await; set type to module; CJS uses require and module.exports and is synchronous. knowing the two module systems and their config.

Node.js & Express1 min read

Why package-lock.json must be committed

Lockfile pins exact versions of the whole dependency tree including transitive deps; guarantees identical installs across machines and CI. understanding reproducible installs.

Node.js & Express1 min read

Resolving core vs relative module specifiers

'fs' is a built-in core module loaded by name with top priority; './my-file.js' is a relative path resolved from the current file. knowledge of module resolution rules.

Node.js & Express1 min read

dependencies vs devDependencies in package.json

Dependencies ship and run in production; devDependencies are only for development; omitted with npm install --production. understanding runtime versus build/test tooling.

Node.js & Express1 min read

Offloading CPU-bound work with Worker Threads

Synchronous CPU work freezes the loop and all requests; offload to a Worker, communicate via messages or SharedArrayBuffer, use a pool. knowing the single thread blocks on CPU work. suggesting async I/O fixes CPU blocking.

Node.js & Express1 min read

nextTick vs setImmediate vs setTimeout(fn, 0)

NextTick is a microtask that drains before the loop continues; setImmediate runs in check; setTimeout(0) in timers. precise ordering of deferral mechanisms.

Node.js & Express1 min read

Order of the Node.js event loop phases

Timers, pending callbacks, poll, check, close phases in order; I/O completion runs in poll. understanding of libuv's loop, not just async vibes. claiming Node is single-phase or fully multithreaded.

Node.js & Express2 min read

The WebSocket Protocol

WebSocket (RFC 6455) is a protocol providing full-duplex, persistent communication over a single TCP connection. It begins as an HTTP request that upgrades, then both client and server can send messages anytime, enabling real-time apps without HTTP's…

Docker & Kubernetes1 min read

Optimize Dockerfile layer caching for npm install

Copying all source first invalidates the npm install layer on any code change; instead copy package.json and lockfile, run npm install, then copy the rest. layer caching mechanics.

Vue, Angular & Svelte2 min read

What is a SvelteKit adapter and how do adapter-static and adapter-node differ?

Tests your grasp of SvelteKit's deployment abstraction. A strong answer outlines how adapters compile the app for a target platform, contrasting adapter-static's CDN-ready HTML with adapter-node's server-side request handler for Node environments.

TypeScript & Web APIs2 min read

How do you configure a dual ESM/CommonJS package?

Use exports.require for .cjs and exports.import for .mjs, keep type unset or explicit, and compile separate artifacts. Node.js conditional exports and the dual-package hazard.

Node.js & Express2 min read

How does Node.js handle thousands of connections on one thread?

This tests non-blocking I/O: Node.js runs one thread for an event loop while the OS handles sockets via epoll or IOCP, resuming callbacks when data arrives. Mention the thread pool for DNS and fs work. A red flag is claiming threads spawn per request.

Node.js & Express2 min read

express-validator: Validate at the Edge

express-validator stops garbage before it hits your logic. Use it on any route that accepts user input like form data, query strings, or JSON payloads. The biggest mistake is validating but forgetting to check validationResult, so invalid requests pass.

Node.js & Express2 min read

Operational vs Programmer Errors in Node

Operational errors are expected problems like a failed network request; programmer errors are bugs like reading undefined. Handle the first gracefully, crash the second. The footgun is catching programmer errors and continuing, which corrupts process state.

Get Nodejs bites daily.

Five a day, five minutes, offline. With quizzes so it sticks.

Open testing — you’ll join as an early tester.