Get Started
Fresher Masterclass: 50+ Q&A

Node.js Essentials: 50+ Fresher Interview Questions & Answers (2026)

Start your backend journey. 50+ essential questions covering Node.js architecture, modules, File System, and basic asynchronous programming for entry-level roles.

interview-prep

1. Core Concepts & Fundamentals (40 Questions)

Q1: What is Node.js?

Answer: Node.js is an open-source, cross-platform JavaScript runtime environment built on Chrome's V8 JavaScript engine. It allows developers to run JavaScript code outside of a web browser, enabling server-side scripting.

Q2: How does Node.js differ from traditional server-side technologies?

Answer:

  • Non-blocking I/O: Uses event-driven, asynchronous architecture

  • Single-threaded: Uses event loop for concurrency

  • JavaScript everywhere: Same language for frontend and backend

  • Fast execution: Built on V8 engine with Just-In-Time compilation

Q3: Explain the event-driven architecture of Node.js

Answer: Node.js uses an event-driven architecture where actions (events) trigger callbacks. The Event Loop continuously checks for events and executes their associated callbacks when they occur.

Q4: What is the Event Loop?

Answer: The Event Loop is Node.js's mechanism for handling asynchronous operations. It continuously checks the call stack and callback queue, pushing callbacks to the stack when it's empty.

Q5: Explain Node.js's single-threaded nature

Answer: Node.js runs on a single main thread but uses worker threads for I/O operations. This allows it to handle thousands of concurrent connections efficiently without creating threads for each connection.

Q6: What are the key features of Node.js?

Answer:

  • Asynchronous and Event Driven

  • Very Fast (V8 Engine)

  • Single Threaded but Highly Scalable

  • No Buffering

  • MIT License

  • Large Ecosystem (NPM)

Q7: What is the V8 JavaScript Engine?

Answer: V8 is Google's open-source JavaScript engine written in C++. It compiles JavaScript directly to native machine code before executing it, making it extremely fast.

Q8: What are the different types of API functions in Node.js?

Answer:

  1. Blocking (Synchronous) Functions: Execute immediately, block further execution

  2. Non-blocking (Asynchronous) Functions: Use callbacks, don't block execution

  3. Promise-based Functions: Return promises, can use async/await

Q9: What is REPL in Node.js?

Answer: REPL stands for Read-Eval-Print-Loop. It's an interactive Node.js shell where you can execute JavaScript code directly.

Q10: How do you start a REPL session?

Answer: Simply type node in the terminal without any filename:

bash
node

Q11: What is process.argv?

Answer: process.argv is an array containing command-line arguments passed when starting the Node.js process.

Q12: What is process.env?

Answer: process.env is an object containing user environment information. Commonly used to access environment variables.

Q13: Explain global objects in Node.js

Answer: Global objects are available in all modules without requiring import. Examples: global, process, console, Buffer, setTimeout, setInterval.

Q14: What is the purpose of __filename and __dirname?

Answer:

  • __filename: Absolute path of the current module file

  • __dirname: Directory name of the current module

Q15: How does Node.js handle child processes?

Answer: Node.js provides child_process module to create child processes. Methods include:

  • spawn(): Launches new process

  • exec(): Runs command in shell

  • fork(): Special case of spawn() for Node.js processes

Q16: What is the difference between development and production modes?

Answer:

  • Development: Detailed error messages, hot reloading, verbose logging

  • Production: Optimized performance, minimal logging, error handling

Q17: How do you set environment to production?

Answer:

bash
export NODE_ENV=production  # Linux/Mac
set NODE_ENV=production     # Windows
# OR in package.json
"scripts": {
  "start": "NODE_ENV=production node app.js"
}

Q18: What is a callback in Node.js?

Answer: A callback is a function passed as an argument to another function, to be executed after the completion of an operation.

Q19: What is callback hell and how to avoid it?

Answer: Callback hell is nested callbacks making code unreadable. Avoid using:

  1. Promises

  2. Async/Await

  3. Modularization

  4. Control flow libraries

Q20: What is N-API?

Answer: N-API is an API for building native addons in Node.js. It's independent of the underlying JavaScript runtime.

Q21: What is libuv?

Answer: libuv is a multi-platform C library that provides support for asynchronous I/O operations. Node.js uses it for the event loop and thread pool.

Q22: How does Node.js handle memory management?

Answer: Node.js uses V8's garbage collector which employs:

  • Generational collection

  • Mark-and-sweep algorithm

  • Incremental collection

  • Memory limits (default ~1.7GB)

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

Answer:

  • process.nextTick(): Executes before the next iteration of the event loop

  • setImmediate(): Executes in the next iteration of the event loop

Q24: What is the purpose of util.promisify()?

Answer: Converts callback-based functions to promise-based functions:

javascript
const util = require('util');
const fs = require('fs');
const readFile = util.promisify(fs.readFile);

Q25: Explain Node.js's module caching

Answer: Node.js caches modules after the first require. Subsequent requires return the cached version.

Q26: What is the difference between require() and import()?

Answer:

  • require(): CommonJS, synchronous, runtime import

  • import(): ES6, asynchronous, static analysis possible

Q27: How does Node.js handle CPU-intensive tasks?

Answer: Node.js uses:

  1. Worker Threads

  2. Child Processes

  3. Clustering

  4. External services/microservices

Q28: What is the purpose of os module?

Answer: The os module provides operating system-related utility methods for memory, CPUs, network interfaces, etc.

Q29: What is the difference between process.exit() and process.kill()?

Answer:

  • process.exit(): Ends process with exit code

  • process.kill(): Sends signal to process (like SIGTERM)

Q30: What is the purpose of util.inherits()?

Answer: Inherits methods from one constructor to another (legacy, use ES6 classes instead).

Q31: How can you check Node.js version?

Answer:

bash
node --version
# OR in code
console.log(process.version);

Q32: What is the purpose of vm module?

Answer: The vm module enables compiling and running code within V8 Virtual Machine contexts.

Q33: What is the difference between process.stdout and console.log?

Answer: console.log internally uses process.stdout.write but adds newline and formatting.

Q34: What are Node.js streams?

Answer: Streams are collections of data that might not be available all at once. Types: Readable, Writable, Duplex, Transform.

Q35: What is the purpose of Buffer class?

Answer: Buffer handles binary data directly, useful for file operations, network communications, etc.

Q36: How does Node.js handle circular dependencies?

Answer: Node.js can handle circular dependencies but returns incomplete modules. Best to avoid by restructuring code.

Q37: What is the purpose of URL module?

Answer: Provides utilities for URL resolution and parsing.

Q38: What is the difference between exports and module.exports?

Answer: exports is a reference to module.exports. Assigning to exports breaks the reference.

Q39: How do you debug Node.js applications?

Answer:

  1. console.log() statements

  2. Node.js debugger (node inspect)

  3. Chrome DevTools (--inspect flag)

  4. VS Code debugger

Q40: What is the purpose of assert module?

Answer: Provides set of assertion functions for testing invariants.


2. Modules & NPM (30 Questions)

Q41: What is a module in Node.js?

Answer: A module is a reusable block of code whose existence does not accidentally impact other code. Each file is treated as a separate module.

Q42: How do you create your own module?

Answer:

javascript
// myModule.js
module.exports = {
  myFunction: function() {
    return "Hello from module";
  }
};

// app.js
const myModule = require('./myModule');
console.log(myModule.myFunction());

Q43: What is package.json?

Answer: package.json is the manifest file for Node.js projects containing metadata, dependencies, scripts, and configuration.

Q44: What is the difference between dependencies and devDependencies?

Answer:

  • dependencies: Required for production

  • devDependencies: Required only for development (testing, building, etc.)

Q45: What is the purpose of package-lock.json?

Answer: Locks dependency versions to ensure consistent installs across environments.

Q46: What is semantic versioning?

Answer: Version format: MAJOR.MINOR.PATCH

  • MAJOR: Breaking changes

  • MINOR: New features, backward compatible

  • PATCH: Bug fixes, backward compatible

Q47: What do ^ and ~ mean in package.json versions?

Answer:

  • ^1.2.3: Accepts minor and patch updates (1.x.x)

  • ~1.2.3: Accepts only patch updates (1.2.x)

  • 1.2.3: Exact version

Q48: How do you update npm packages?

Answer:

bash
npm update              # Update all packages
npm update <package>    # Update specific package
npm outdated            # Check for outdated packages

Q49: What is npx?

Answer: npx is a package runner that executes packages without installing them globally.

Q50: What is the difference between npm install and npm ci?

Answer:

  • npm install: Installs packages, updates lockfile

  • npm ci: Clean install, uses lockfile exactly, deletes node_modules first

Q51: How do you create global packages?

Answer:

bash
npm install -g <package-name>
# OR in package.json
"bin": {
  "my-cli": "./cli.js"
}

Q52: What is npm scripts?

Answer: Commands defined in package.json that can be run with npm run <script-name>.

Q53: What is the purpose of .npmrc file?

Answer: Configuration file for npm containing registry settings, authentication, etc.

Q54: How do you publish a package to npm?

Answer:

bash
npm login
npm publish
# Private packages require paid account

Q55: What is npm audit?

Answer: Scans project dependencies for security vulnerabilities.

Q56: How do you fix npm audit vulnerabilities?

Answer:

bash
npm audit fix          # Fix automatically
npm audit fix --force  # Fix breaking changes

Q57: What is the purpose of engines field in package.json?

Answer: Specifies Node.js and npm versions required:

json
"engines": {
  "node": ">=14.0.0",
  "npm": ">=6.0.0"
}

#career

Ready to Build Your Resume?

Create a professional resume that stands out to recruiters with our AI-powered builder.

Node.js Essentials: 50+ Fresher Interview Questions & Answers (2026) | Hirecta Interview Prep | Hirecta