Interview Prep
Node.js interview questions and how to answer them
Node interviews test your understanding of async JavaScript at the server level: the event loop, non-blocking I/O, and what happens when you get that wrong. These are the questions that come up most in backend and full-stack interviews.
PrepVault maps your skills to the job and keeps your study guides in one place. Free to start.
Node.js interview questions and how to answer them
What are npm scripts and how do you use them?
defined in package.json scripts. locally installed bins on PATH. start/test are special. pre/post hooks available
How would you compare CommonJS modules and ES modules in Node.js?
CommonJS uses require and module.exports. ES modules use import and export. Modern JavaScript increasingly uses ES modules. Configuration may affect module support. Both approaches organize reusable code
How would you create a GET route in Express?
Express routes handle HTTP requests. GET routes retrieve data. Routes include a path and callback. Responses are commonly JSON. Express organizes endpoint handling
What production metrics are most important for Node.js performance and clustering?
track user impact metrics. measure Node runtime health. break down by worker. alert on SLO and saturation
How do you serve static files in Express, and what should you consider in production?
express static serves files. mount under a prefix. cache hashed assets. do not expose project root
What is the difference between __dirname in CommonJS and import.meta.url in ES modules?
CommonJS provides __dirname. ESM uses import.meta.url. fileURLToPath converts URLs. process cwd is not module-relative
What are Node.js streams and when would you use them?
four types: Readable, Writable, Duplex, Transform. chunks not full buffer. pipe handles backpressure. pipeline cleans up on error
When would you use require in a Node.js application?
require imports CommonJS modules. Modules help organize code. Node.js historically used CommonJS. Reusable code improves maintainability. module.exports exposes functionality
How do application-level and router-level middleware differ in Express?
app middleware can be global. router middleware is scoped. both depend on order. routers support modular route groups
What is Express error-handling middleware, and why does it use four arguments?
four arguments identify error middleware. next error enters error flow. register after routes. avoid leaking internals
Common mistakes
- Blocking the event loop without realizing
- Vague on async patterns and streams
- Mixing up server and browser JavaScript
What interviewers weigh
- Understanding non-blocking I/O
- How you structure an API
- Error handling in async code