Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.
Answer: sync function read() { const content = await readFile('file.txt', 'utf8'); console.log(content); } What interviewers expect A clear definition tied to Node.js in Node.js projects Trade-offs (performance, maintain…
process is a global object that provides information and control over the current Node.js process. 📌 Examples: console.log(process.pid); // Process ID console.log(process.platform); // OS platform You can also handle ex…
Both create child processes, but: spawn() streams data (good for large outputs) exec() buffers data (good for small outputs) const { spawn, exec } = require('child_process'); // spawn example const ls = spawn('ls', ['-lh…
__dirname: Returns the directory path of the current module. __filename: Returns the full file path of the current module. 📌 Example: console.log(__dirname); // /Users/yourname/project console.log(__filename); // /Users…
Answer: EventEmitter is a core class that allows objects to emit named events and register listeners to respond. What interviewers expect A clear definition tied to Node.js in Node.js projects Trade-offs (performance, ma…
NPM stands for Node Package Manager. It is the default package manager for Node.js and is used to install, share, and manage reusable packages or libraries. It comes pre-installed with Node.js and gives you access to a h…
Answer: Blocking happens when synchronous code takes too long, preventing other events from processing. Detect with tools like: clinic.js — Event Loop Delay tool. Manual timing (setInterval to check delay). What intervie…
Answer: pp.use((req, res, next) => { console.log('Middleware 1'); next(); }); pp.use((req, res, next) => { console.log('Middleware 2'); res.send('Done'); }); What interviewers expect A clear definition tied…
dependencies: These are required for your app to run in production. 📌 Example: express, mongoose devDependencies: Only needed during development (testing, building, linting). 📌 Example: nodemon, eslint, jest 📦 These a…
Semantic Versioning (semver) is a versioning system that uses the format: MAJOR.MINOR.PATCH Example: 2.5.3 MAJOR: Breaking changes MINOR: New features, no breaking changes PATCH: Bug fixes, backwards-compatible 📌 Exampl…
Answer: The cluster module lets you fork your Node.js process to create worker processes that share the same server port, improving CPU utilization. Testing Node.js Applications What interviewers expect A clear definitio…
Answer: Ensuring incoming data matches expected format to avoid injection attacks, crashes, or invalid data storage. What interviewers expect A clear definition tied to Node.js in Node.js projects Trade-offs (performance…
pplications. It uses standard HTTP methods to perform CRUD operations on resources, which are typically represented as URLs. ✅ A RESTful API allows different systems (like frontend apps or mobile apps) to interact with y…
Answer: pplications and APIs by handling routing, middleware, requests, responses, and more. ✅ It’s like jQuery for the backend — removes the boilerplate. What interviewers expect A clear definition tied to Node.js in No…
Answer: n operation is idempotent if repeating it has the same effect as doing it once (e.g., PUT). Important for safe retries. What interviewers expect A clear definition tied to Node.js in Node.js projects Trade-offs (…
Answer: pp.get('/users/:id', (req, res) => { const id = req.params.id; res.send(`User ID: ${id}`); }); Request to /users/42 returns: User ID: 42 What interviewers expect A clear definition tied to Node.js in Node.…
Answer: Stateless: Each request is independent; no session stored on server. Stateful: Server keeps session info (like login status). Stateless apps scale easier. Testing & Debugging What interviewers expect A cl…
Answer: pp.use((req, res, next) => { console.log(`${req.method} ${req.url}`); next(); // Move to next middleware or route }); What interviewers expect A clear definition tied to Node.js in Node.js projects Trade-o…
Answer: Write tests before code, then develop just enough to pass tests. Use frameworks like Mocha or Jest. What interviewers expect A clear definition tied to Node.js in Node.js projects Trade-offs (performance, maintai…
Answer: pp.use () Middleware for all requests pp.get () Handle only GET requests 📌 Example: pp.use(authMiddleware); // Runs on all routes pp.get('/data', handler); // Runs only for GET /data What interviewers expect A c…
Answer: pp.use((req, res) => { res.status(404).json({ message: 'Route not found' }); }); What interviewers expect A clear definition tied to Node.js in Node.js projects Trade-offs (performance, maintainability, se…
Answer: Node Version Manager lets you install and switch between Node.js versions easily. What interviewers expect A clear definition tied to Node.js in Node.js projects Trade-offs (performance, maintainability, security…
Answer: npm: Default Node package manager. yarn: Faster installs, better caching. pnpm: Efficient disk usage by linking packages. What interviewers expect A clear definition tied to Node.js in Node.js projects Trade-offs…
Answer: Babel: Transpiles modern JS to compatible versions. TypeScript: Adds static typing and compiles to JS. What interviewers expect A clear definition tied to Node.js in Node.js projects Trade-offs (performance, main…
Node.js Node.js Tutorial · Node.js
Answer: sync function read() { const content = await readFile('file.txt', 'utf8'); console.log(content); }
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
process is a global object that provides information and control over the current Node.js
process.
📌 Examples:
console.log(process.pid); // Process ID
console.log(process.platform); // OS platform
You can also handle exit events:
process.on('exit', () => {
console.log('Exiting...');
});
Node.js Node.js Tutorial · Node.js
Both create child processes, but:
const { spawn, exec } = require('child_process');
// spawn example
const ls = spawn('ls', ['-lh', '/usr']);
ls.stdout.on('data', (data) => console.log(`Output: ${data}`));
// exec example
exec('ls -lh /usr', (error, stdout) => console.log(stdout));Node.js Node.js Tutorial · Node.js
📌 Example:
console.log(__dirname); // /Users/yourname/project
console.log(__filename); // /Users/yourname/project/app.js
These are very useful for reading or writing files relative to the script's location.
PM and Module Management
Node.js Node.js Tutorial · Node.js
Answer: EventEmitter is a core class that allows objects to emit named events and register listeners to respond.
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
NPM stands for Node Package Manager. It is the default package manager for Node.js and
is used to install, share, and manage reusable packages or libraries.
It comes pre-installed with Node.js and gives you access to a huge ecosystem of
open-source tools.
📌 Example Use:
npm install express
This command downloads the Express.js library into your project.
✅ NPM also:
Node.js Node.js Tutorial · Node.js
Answer: Blocking happens when synchronous code takes too long, preventing other events from processing. Detect with tools like: clinic.js — Event Loop Delay tool. Manual timing (setInterval to check delay).
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: pp.use((req, res, next) => { console.log('Middleware 1'); next(); }); pp.use((req, res, next) => { console.log('Middleware 2'); res.send('Done'); });
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
📌 Example: express, mongoose
📌 Example: nodemon, eslint, jest
📦 These are defined in package.json:
"dependencies": {
"express": "^4.18.0"
},
"devDependencies": {
"nodemon": "^3.0.0"
}
✅ Install a dev dependency with:
npm install nodemon --save-dev
Node.js Node.js Tutorial · Node.js
Semantic Versioning (semver) is a versioning system that uses the format:
MAJOR.MINOR.PATCH
Example: 2.5.3
📌 Example:
If a package moves from 1.2.0 to 2.0.0, it likely has breaking changes.
In package.json, you might see:
"express": "^4.17.1"
Node.js Node.js Tutorial · Node.js
Answer: The cluster module lets you fork your Node.js process to create worker processes that share the same server port, improving CPU utilization. Testing Node.js Applications
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: Ensuring incoming data matches expected format to avoid injection attacks, crashes, or invalid data storage.
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
pplications. It uses standard HTTP methods to perform CRUD operations on resources,
which are typically represented as URLs.
✅ A RESTful API allows different systems (like frontend apps or mobile apps) to interact
with your server over HTTP in a stateless manner.
📌 Example:
Node.js Node.js Tutorial · Node.js
Answer: pplications and APIs by handling routing, middleware, requests, responses, and more. ✅ It’s like jQuery for the backend — removes the boilerplate.
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: n operation is idempotent if repeating it has the same effect as doing it once (e.g., PUT). Important for safe retries.
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: pp.get('/users/:id', (req, res) => { const id = req.params.id; res.send(`User ID: ${id}`); }); Request to /users/42 returns: User ID: 42
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: Stateless: Each request is independent; no session stored on server. Stateful: Server keeps session info (like login status). Stateless apps scale easier. Testing & Debugging
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: pp.use((req, res, next) => { console.log(`${req.method} ${req.url}`); next(); // Move to next middleware or route });
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: Write tests before code, then develop just enough to pass tests. Use frameworks like Mocha or Jest.
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: pp.use () Middleware for all requests pp.get () Handle only GET requests 📌 Example: pp.use(authMiddleware); // Runs on all routes pp.get('/data', handler); // Runs only for GET /data
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: pp.use((req, res) => { res.status(404).json({ message: 'Route not found' }); });
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: Node Version Manager lets you install and switch between Node.js versions easily.
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: npm: Default Node package manager. yarn: Faster installs, better caching. pnpm: Efficient disk usage by linking packages.
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: Babel: Transpiles modern JS to compatible versions. TypeScript: Adds static typing and compiles to JS.
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.