# Top Node.js Interview Questions

Aced (formerly Exponent) publishes a public search API over its indexed pages; the guide is at https://www.aced.io/agents/agent-access.

Source: https://www.aced.io/blog/top-node-js-interview-questions
Source observed: 2026-11-05T00:52:46.972Z
Last checked: 2026-11-05T00:52:46.972+00:00
Indexed: 2026-11-07T04:01:24.984+00:00

---

# Top Node.js Interview Questions

**Software Engineering** · Tatsat Jha · Last updated a month ago

We created this guide to help you prepare for software engineering interviews involving backend or full-stack development. It explains Node.js fundamentals, common applications, package management, asynchronous execution, servers, middleware, scalability, and trade-offs. For broader preparation, use our [software engineering interview course](https://www.aced.io/courses/software-engineering?ref=exponent-blog.ghost.io).

## Questions covered

- [What is Node.js and what are its advantages?](https://www.aced.io/blog/top-node-js-interview-questions#what-is-nodejs-and-what-are-its-advantages)
- [What are common applications of Node?](https://www.aced.io/blog/top-node-js-interview-questions#what-are-some-common-applications-of-node)
- [How are Node packages managed?](https://www.aced.io/blog/top-node-js-interview-questions#how-are-node-packages-managed)
- [How is npm different from npx?](https://www.aced.io/blog/top-node-js-interview-questions#how-is-npm-different-from-npx)
- [How do importing and exporting work in Node?](https://www.aced.io/blog/top-node-js-interview-questions#explain-importing-and-exporting-in-node)
- [What are callbacks?](https://www.aced.io/blog/top-node-js-interview-questions#what-do-you-understand-about-callbacks)
- [What does single-threaded mean?](https://www.aced.io/blog/top-node-js-interview-questions#what-does-it-mean-that-nodejs-is-single-threaded)
- [Synchronous versus asynchronous execution](https://www.aced.io/blog/top-node-js-interview-questions#what-is-meant-by-synchronous-vs-asynchronous)
- [Blocking versus non-blocking execution](https://www.aced.io/blog/top-node-js-interview-questions#what-is-meant-by-blocking-vs-non-blocking)
- [What is the Node.js event loop?](https://www.aced.io/blog/top-node-js-interview-questions#what-is-the-nodejs-event-loop)
- [What is livbuv?](https://www.aced.io/blog/top-node-js-interview-questions#what-do-you-understand-about-livbuv)
- [The EventEmitter API](https://www.aced.io/blog/top-node-js-interview-questions#explain-the-eventemitter-api)
- [Child processes and how to create them](https://www.aced.io/blog/top-node-js-interview-questions#what-is-a-child-process-in-nodejs-and-how-are-they-created)
- [Creating a Node.js server](https://www.aced.io/blog/top-node-js-interview-questions#how-do-you-create-a-server-in-nodejs)
- [Middleware](https://www.aced.io/blog/top-node-js-interview-questions#explain-middleware)
- [Advantages and drawbacks of Node.js](https://www.aced.io/blog/top-node-js-interview-questions#explain-the-advantages-vs-the-drawbacks-of-using-nodejs)

## What is Node.js and what are its advantages?

Node.js is an open-source, cross-platform JavaScript runtime that runs JavaScript outside the browser. Ryan Dahl released it in 2009. It uses Chrome's V8 engine and is described here as lightweight, fast, and highly scalable. Node's major building blocks include non-blocking I/O, asynchronous execution, and the event loop.

Its large ecosystem of open-source Node packages adds functionality through reusable modules.

## Common applications of Node.js

Node provides a runtime for handling file systems, operating systems, servers, APIs, and other general programming tasks. It is commonly used for:

- Backend web applications
- REST APIs
- Microservice architectures
- Networking tasks
- Fast, scalable, data-intensive real-time applications

Using Node can also allow JavaScript to serve as the main language across the frontend and backend.

## Managing Node packages

Most Node projects use npm together with `package.json` and `package-lock.json`. These files describe dependencies and development scripts. An empty `package.json` example is shown below:

```json
{
  "name": "example",
  "version": "0.1.0",
  "private": true,
  "homepage": ".",
  "dependencies": {},
  "scripts": {},
  "eslintConfig": {
    "extends": []
  },
  "browserslist": {
    "production": [],
    "development": []
  },
  "devDependencies": {}
}
```

Express is an example of a Node package that can support a project. Yarn is an alternative to npm.

## npm versus npx

**npm**, the Node Package Manager, installs and updates third-party Node packages. **npx**, the Node Package Executer, directly executes a package without first installing it. The guide gives `create-react-app` as an example of a package that can be executed rather than installed.

## Importing and exporting modules

The `require` keyword imports modules such as `fs`, `http`, and `os`. `module.exports` makes a function or other value available elsewhere in the project through `require`.

```js
const fs = require("fs");
const os = require("os");
const http = require("http");

const function Example(){
//some functional code
}

module.exports = Example;
```

## Callbacks

A callback is code that runs after a task while allowing other parts of the program to run first, avoiding blocking. Callbacks are used throughout Node's internals.

```js
function processData (callback) {
  fetchData(function (err, data) {
    if (err) {
      console.log("An error has occurred. Abort everything!");
      return callback(err);
    }
    data += 1;
    callback(data);
  });
}
```

This is presented as a basic callback sample from the Node documentation. Promises and ES6 `async/await` provide newer approaches with improved readability, error handling, and control flow.

## Single-threaded execution

A thread is a sequence of instructions or commands. In the simplified model used here, the Node runtime has one thread handling requests, yet it can handle concurrent events. Asynchronous execution and non-blocking I/O are central to this behavior.

## Synchronous versus asynchronous execution

Synchronous code waits for an operation to finish before continuing and executes in the order it appears. Asynchronous code does not make Node wait; Node moves to the next task while the operation completes elsewhere.

Non-blocking I/O relies on asynchronous execution. I/O includes disk and network operations such as HTTP requests, which can be time-intensive and should be handled asynchronously so the single thread remains available.

## Blocking versus non-blocking execution

A blocking operation prevents further execution until it finishes. Node supports both blocking and non-blocking calls. Blocking calls are synchronous; non-blocking calls are asynchronous. Node APIs often identify blocking counterparts with `sync` at the end of the function name.

Blocking and non-blocking calls are distinct from the broader concept of non-blocking I/O: the latter describes handling I/O asynchronously so the thread is not held up.

## The Node.js event loop

The event loop enables asynchronous functions and non-blocking I/O. Node executes JavaScript on its thread and offloads asynchronous or I/O operations to the system kernel. The kernel can handle multiple operations asynchronously. The event loop tracks unfinished operations and checks them until they complete.

## `livbuv`

The article calls `livbuv` a C library used under Node's hood for lower-level non-blocking I/O and event-loop operations. It describes the library as allowing CPU resources to be used simultaneously and as also handling child processes and the file system.

## The EventEmitter API

`EventEmitter` belongs to Node's `events` module. It lets backend servers emit and handle custom events asynchronously.

- `emit` triggers an event.
- `on` registers a callback to handle a specified event.
- Other methods include `once` and `removeListener`.

## Child processes and clusters

A single-threaded event loop can be limited under heavy load. Node's `child_process` module creates additional processes for handling events or executing code. Its two principal creation methods are:

- `spawn()`: creates a new process implementing `EventEmitter`; the process can handle events and communicate through messaging.
- `fork()`: a specialized form of `spawn()` in which the parent and child communicate directly. Memory-intensive work can be moved to a forked process to free the main event loop.

The `cluster` module distributes workloads across multiple processes. Each clustered child process runs its own thread, shares the server port, and can use multiple CPU cores. New cluster processes are created with `cluster.fork()`.

Relevant cluster methods and properties include `disconnect()` for disconnecting workers, `send()` for inter-process communication, and `worker` for obtaining a worker object. Cluster adds process-forking functionality on top of the `child_process` module.

## Creating an HTTP server

Node's `http.createServer()` accepts a `requestListener` that responds to requests:

```js
const http = require('http');

const requestListener = function (req, res) {
  res.writeHead(200);
  res.end('Hello, World!');
}

const server = http.createServer(requestListener);
server.listen(8080);
```

For more complex server architectures such as REST APIs, the guide recommends a framework such as Express, while noting that similar underlying methods are used.

## Middleware

Middleware is code between an incoming request and the relevant business logic. It can execute code, parse request or response objects, end a request/response cycle, and perform other processing. Common Node middleware tasks include authentication and routing.

## Advantages and drawbacks

### Advantages

The guide groups Node's main advantages into five areas:

1. **High performance:** V8 is a fast JavaScript engine maintained by Google and implemented in C++. The event loop, asynchronous execution, and non-blocking I/O—described here as enabled by the `livbuv` library written in C—support network applications.
2. **Scalability:** The single-threaded event loop is memory-friendly, while child processes and clusters distribute work across multiple cores.
3. **Ease of learning:** Developers familiar with vanilla JavaScript mainly need to learn package managers, built-in Node modules, and Node's architecture. The `http` module is enough to begin building a backend.
4. **Full-stack JavaScript:** Using JavaScript throughout the stack can reduce coordination and DevOps friction between frontend and backend work.
5. **Extensibility:** npm and the wider Node ecosystem provide modules and tools for IPC, sockets, REST APIs, and other backend tasks. Socket.io can simplify client-server communication, while Express can accelerate server and API development compared with using the `http` module manually.

### Drawbacks

- The codebase contains legacy projects, making modernization and new-feature development difficult.
- Changes that do not preserve backward compatibility can require developers to adjust projects; the guide describes the Node API as rarely stable.
- Heavy computational tasks can cause problems if child processes are not configured appropriately.
- The large package ecosystem can be difficult to navigate: packages may duplicate existing projects, bring many dependencies, or have limited library support.

The guide also mentions Deno, a runtime released by Node creator Ryan Dahl in 2020, as an alternative intended in some respects as an evolution beyond Node.

## Continue preparing with Aced

- [Browse software engineer interview questions](https://www.aced.io/questions?role=swe&src=blog) from real candidates.
- [Book time with a Software Engineer coach](https://www.aced.io/coaching?role=swe) for mock interviews, career coaching, or resume review. 
- [Create a free account](https://www.aced.io/signup?src=blog). We describe Aced as a tech interview preparation platform offering free interview guides, insider tips, and courses.

### Related courses

- [Software Engineering Interview Prep Course](https://www.aced.io/courses/software-engineering) — **5 courses, 41,700 students**. Covers mock interviews, frameworks, advice from senior candidates, data structures, algorithms, system design, people management, behavioral interviews, and preparation for companies including Google, Amazon, Microsoft, Meta, and Apple.
- [Amazon Software Development Engineer (SDE) Interview Course](https://www.aced.io/courses/amazon-sde-interview) — **5 courses, 4,600 students**. Covers data structures, algorithms, system design, detailed questions, mock interviews, and Amazon leadership principles.

### Related blog posts

- [20 Docker Interview Questions & Answers to Rule Them All](https://www.aced.io/blog/top-docker-interview-questions) — a month ago · 10 min read
- [Microservices and distributed systems are unreliable. Here's what to do about it](https://www.aced.io/blog/microservices-and-distributed-systems-are-unreliable-heres-what-to-do-about-it) — 4 years ago · 1 min read
- [Top 15 SQL Interview Questions and Answers (with Examples)](https://www.aced.io/blog/top-sql-interview-questions) — a month ago · 13 min read
- [Top React Interview Questions for Experienced and Beginner Developers](https://www.aced.io/blog/top-react-interview-questions) — a month ago · 13 min read

![Node.js interview guide artwork](https://storage.ghost.io/c/a5/f5/a5f5c2f0-4c62-43c7-891b-662a0b6d68b3/content/images/2022/09/mega-creator--8-.png)

---

[Read this page’s summary](https://www.aced.io/agents/api/public/v1/page-tldr?url=https%3A%2F%2Fwww.aced.io%2Fblog%2Ftop-node-js-interview-questions&trace=t_679ff9ab98f3)

## Ask a follow-up about this page

Need a more specific answer? Ask the exact question you have. It returns a fresh, cited answer from Aced (formerly Exponent)’s knowledge base. No account or API key required.

Open this URL with your own question, URL-encoded. Include your question in q. All research inputs are optional; no account or setup.

`GET https://www.aced.io/agents/agent/faq?q={question}&trace=t_679ff9ab98f3`

[Tool guide and examples](https://www.aced.io/agents/agent-access) · [OpenAPI](https://www.aced.io/agents/api/public/v1/openapi.json) · [Page TLDR form](https://www.aced.io/agents/agent-tools/page-tldr?url=https%3A%2F%2Fwww.aced.io%2Fblog%2Ftop-node-js-interview-questions). Opening a form does not execute a tool.