30 essential questions to interview a Node.js developer

#dedicated teams

You are on this page. Let us guess. You heard about Node.js huge popularity. You don’t mind hitting the ground running like PayPal, LinkedIn, Netflix, and Yahoo did, do you? Yes, they decided to Node one day. You are on the lookout for an ably Node.js developer, are you? So, it’s high time to roll up your sleeves and get down to work.

We pinned down 30 essential interview questions and answers to help you match your wants with the skilled Node.js haves. The question complexity level is marked with ★.

Note: The following questions and answers are merely examples and not interview benchmark.

Here we go

What is Node.js? What is it used for?
View the answer

Node.js is neither a programming language nor a framework of any kind. It is an open-source server-side platform used to develop such applications written in JavaScript as: websites, real-time applications, interactive apps, REST API servers, APIs, dashboards, and plug-ins. Node.js uses an event-driven and non-blocking I/O (Input/Output) model, which allows building lightweight, fast, scalable and highly responsive web applications.

Which dependencies does Node.js rely on?
View the answer

There are several dependencies that Node.js relies on to work the way it should. These are libraries and tools. The libraries include V8, libuv, http-parser, c-ares, OpenSSL and zlib. The tools include npm, gyp and gtest.

What is V8?
View the answer

V8 is an open source JavaScript engine, which was originally developed in C++ for the desktop Google Chrome browser. V8 converts JavaScript language into the readable format for the machine to execute the resulting code without referring to the intermediate language Bytecode. This allows increasing browser performance and avoiding memory leaks.

In 2009, Ryan Dahl, the creator of Node.js, modified the V8 source code to the extent it can be also effectively used for the server-side applications. V8 is portable and runs on Mac, Windows, and Linux.

What's libuv?
View the answer

libuv is built in the server Node.js. libuv is a cross-platform library responsible for event-driven asynchronous I/O (Input/Output) based on the event loop.

What is the event loop?
View the answer

The event loop is the process that keeps running all the time. The event loop continuously checks the call stack to see whether there are any function calls that need to be run. When the call stack is empty, the first callback in the callback queue is pushed onto the call stack to complete the execution. This happens until the queue is empty.

What are the phases of the event loop?
View the answer

timers runs callbacks scheduled by setTimeout() and setInterval().

pending callbacks executes I/O callbacks deferred to the next loop iteration.

idle, prepare is used internally, only.

poll retrieves new I/O events; executes I/O related callbacks (almost all with the exception of close callbacks, the ones scheduled by timers, and setImmediate()); node will block here when appropriate.

check invokes setImmediate() callbacks.

close callbacks executes close callbacks, e.g. socket.on('close', ...).

The event loop phases

The event loop phases.

What are microtasks and macrotasks in the event loop?
View the answer

JavaScript puts all the tasks into the queue before executing on something. There are macrotasks and microtasks. These two types of tasks occupy different queues, and they don’t mix. For each event loop cycle, one macrotask is executed out of the macrotasks queue. After the macrotask is complete, the event loop checks the microtask queue and runs all the microtasks.

Examples of Macro: setTimeout, setInternal, setImmediate, I/O tasks

Examples of Micro: process.nextTick, Promises

What is blocking and non-blocking I/O?
View the answer

Blocking I/O refers to an operation that blocks further execution until the given operation finishes.

const fs = require('fs');
const data = fs.readFileSync('/'); // blocks here until file is read
moreWork(); // will run after console.log

Non-blocking I/O refers to an operation that doesn't block execution.

const fs = require('fs');
fs.readFile('/', (err, data) => {
  if (err) throw err;
moreWork(); // will run before console.log

What are the ways to work with asynchronous code in Node.js?
View the answer

There are several ways of how to handle asynchronous code in Node.js:


fs.readFile('input.txt', function (err, data) {
  if (err) return console.error(err);


  .then((result) => {})
  .catch((error) => {});


const func = async () => {
  try {
    const result = await httpGet('/article/promise/userNoGithub.json');
  } catch (error) {

What will be printed in console in LTS version of Node.js?
setTimeout(() => {
}, 0);
View the answer

1, 4, 3, 2

What is npm?
View the answer

npm stands for the node package manager. It consists of a command line tool that is used to install, update, or uninstall JavaScript libraries for Node.js projects. npm is also an-open source repository for the node community to share their packages (modules). npm comes with the the Node.js installation.

What's nvm?
View the answer

nvm stands for the node version manager. It is a command line tool used to install different versions of Node.js, switch between the versions and rollback to a previous version if something works wrong or breaks in a newer version.

What are the globals in Node.js?
View the answer

Node.js globals are objects available in all modules. The following variables may appear to be global but they are not. They exist only in the scope of modules: __dirname, __filename, exports, module, require(). There is a number of built-in objects that are part of the JavaScript language itself, which are also globally accessible.

What is EventEmitter in Node.js?
View the answer

Node.js core API is based on an asynchronous event-driven architecture. This means that certain kinds of objects (called "emitters") periodically emit events that cause function objects ("listeners") to be called.

For instance, net.Server object emits an event each time a peer connects to it. fs.ReadStream emits an event when the file is opened. A stream emits an event whenever data is available to be read.

All objects that emit events are instances of the EventEmitter class. When the EventEmitter object emits an event, all of the functions attached to that specific event are called synchronously. Any values returned by the called listeners are ignored and will be discarded.

What is Buffer?
View the answer

Prior to the introduction of TypedArray, pure JavaScript language had no mechanism for handling streams of binary data. With the introduction of Buffer global class as part of the Node.js API, it now becomes possible to interact with octet streams in TCP streams, file system operations, and other contexts.

With TypedArray available, the Buffer class implements the Uint8Array API in a manner that is more optimized and suitable for Node.js. Instances of the Buffer class are similar to arrays of integers from 0 to 255, but correspond to fixed-sized, raw memory allocations outside the V8 heap. The size of the Buffer is established when it is created and cannot be changed.

What's the stream in the Node.js?
View the answer

A stream is an abstract interface for working with streaming data in Node.js. The stream module provides an API for implementing the stream interface. There are many stream objects provided by Node.js. For instance, a request to an HTTP server and process.stdout are both stream instances. All streams are instances of EventEmitter.

There are four fundamental stream types within Node.js:

Writable streams to which data can be written (for example, fs.createWriteStream()).

Readable streams from which data can be read (for example, fs.createReadStream()).

Duplex streams that are both Readable and Writable (for example, net.Socket).

Transform are Duplex streams that can modify or transform the data as it is written and read (for example, zlib.createDeflate()).

What are the error conventions (error-first pattern)?
View the answer

It is a standard practice for Node.js to handle errors in asynchronous functions by returning them as the first argument to the current function's callback. If there is an error, the first parameter is passed an Error object with all the details. Otherwise, the first parameter is null.

Is it possible to run multiple tasks in parallel for Node.js?
View the answer

Yes. Even though Node.js is one-threaded, it is possible to execute multiple tasks at the same time without waiting until the previous task is completed. Parallel execution saves time and improves a Node.js application performance as it utilizes the CPU power of a machine to the fullest. There are several ways to execute Node.js in parallel by using the capabilities of multi-core processors:

cluster module allows easy creation of child processes sharing the same server port. The worker processes are spawned using the child_process.fork() method, so that they can communicate with the parent via IPC and pass server handles back and forth.

child_process module allows spinning of a child process. The child processes communicate with each other via a messaging system. The child_process module allows accessing the OS functionalities by running any system command inside a child process.

worker_threads module comes in handy for executing CPU-intensive JavaScript operations. Unlike the child_process or cluster modules, the worker_threads module can share memory by transferring ArrayBuffer instances or sharing SharedArrayBuffer instances.

pm2 simplifies the execution of Node.js applications run as a cluster. PM2 creates a given number of worker processes without referring to the cluster module.

How to work with the file system in Node.js?
View the answer

The fs module provides an API for interacting with the file system in a manner closely modeled around standard POSIX functions.

const fs = require('fs');
fs.readFile('/etc/passwd', (err, data) => {
  if (err) throw err;

What are the modules in Node.js?
View the answer

Modules in Node.js are the same as libraries in JavaScript. They are organized in a single or multiple JavaScript files and provide simple or complex functions to build Node.js applications. Each module in Node.js has its own context, so it cannot interfere with other modules. There are built-in modules in Node.js, which come with the installation. It is also possible to create custom modules. Node.js implements CommonJS modules standard.

Node.js includes the following three types of modules:

Core Modules with the minimum Node.js functionality.

Local Modules that are created in the Node.js application locally.

Third Party Modules as a third-party code the developer can use from npm.

What is an environment variable?
View the answer

An environment variable is used to manage the application configuration independently of the code base in development and production environments. The variable value is set outside the application in the OS or microservice functionality. An environment variable consists of a name/value pair. Node.js provides all environment variables within the global variable process.env object.

What will be printed in console after 1 sec and how to fix it?
const user = {
  firstName: 'Вася',
  sayHi() {
setTimeout(user.sayHi, 1000);
View the answer




setTimeout(() => user.sayHi(), 1000);


setTimeout(user.sayHi.bind(user), 1000);

Write makeCounter() function;
const counter = makeCounter();
console.log( counter() ); // 1
console.log( counter() ); // 2
console.log( counter() ); // 3
View the answer
const makeCounter = () => {
  let count = 0;
  return () => ++count;

Write function arrayToObj(array) that converts array into object?
View the answer
const arrayToObj = array => array.reduce((result, item, index) => {
  result[index] = item;
  return result;
}, {});

What are the most popular Node.js testing frameworks?
View the answer

The most popular Node.js frameworks are as follows: Mocha, Jest, Jasmine and Karma.

What are assertion libraries? Which commonly used assertion libraries do you know?
View the answer

The Node.js developer uses assertion libraries to test their code instead of writing multiple if statements. The commonly used assertion libraries are as follows: - assert built-in node.js module, Chai, Jest, Expect and Jasmine.

What is the express.js framework used for?
View the answer

Express.js is a server framework designed for building single-page, multi-page, and hybrid web applications. The Express.js framework makes it easy to develop applications that handle multiple types of requests like GET, PUT, POST and DELETE requests.

What are session- and token-based authentications? What is the difference between them?
View the answer

In the session-based authentication, the server creates a session once the user has logged in. The session ID is stored in a cookie within the user’s browser. While the user stays logged in, the cookie is sent along with every subsequent request. To verify the user's identity, the server compares the session ID stored in the cookie against the session information stored in the memory.

Many applications use JSON Web Token (JWT) instead of sessions and cookies for user’s authentication. JWT is a security token. The server creates it and sends to the client. Whenever the client sends the token along with the request, the server validates it and sends a corresponding response to the client.

The difference between the above authentication methods is where the user’s information is stored. For the session-based authentication, the user’s information is stored on the server. For the token-based authentication, the user’s information is stored on the client side.

What is the passport.js library? What are the strategies?
View the answer

Passport.js is authentication middleware for Node.js. Thanks to its flexible and modular nature, it is possible to realize a variety of authentication strategies for Node.js applications. Authentication strategies are packed as dedicated modules. For instance, we can implement Facebook - or Twitter-based authentication, where the user logs in to the application via any of the social accounts.

What is helmet.js?
View the answer

Helmet.js is a Node.js module for securing applications. Helmet.js represents a collection of middleware functions that set security-related HTTP response headers. For instance, csp sets the Content Security Policy header to prevent cross-site scripting attacks and other cross-site injections.

At the end of the day...

There is always more to interviewing than posing technical questions. Spotless answers should not always signal that a candidate is a perfect fit for your project. Failing to answer at least one simple answer in no way proves the developer’s tech incompetence.

Got lost? Keep in touch. Tricks and tips for a non-technical interview are coming soon...

Let's get rolling
Drive your business, and get solutions,
not just technologies.
Have a project in mind?
We'll help you develop this idea into a great solution.
Give us a shout!