Node.js Interview Questions

Want to become an expert in cracking Node.js interview questions?

Start with practicing the questions below. Whether a question involves multiple choice or live coding, we will give you hints as you go and tell you if your answers are correct or incorrect.

After that, take our timed public Node.js Interview Questions Test.

To use our service for testing candidates, buy a pack of candidates.


1. Config

Node.js NPM Public New

Consider the following package.json for a Node.js application:

{
  "name": "skill-measure-app",
  "private": true,
  "version": "1.0.0",
  "main": "lib/main.js",
  "scripts": {
    "build": "npm run cleanup & npm run test & npm run publish",
    "cleanup": "rm -fr ./lib",
    "test": "jest",
    "publish": "npm publish lib"
  },
  "dependencies": {
     "jest": "^23.0.1",
     "custom-package": "file:../custom-package"
  }
}

Select all the correct statements.

(multiple correct answers possible)

Easy 
3min
   


2. Http Server

Node.js Standard Library Public New

A company hosts its website and a product API on same server using the code below:

let http = require('http');

let commonResponse = function(response){
  response.writeHead(200, { "Content-Type": "text/html" });
  response.write("Request Complete");
}

let handleApi = function(req, res){
  if(req.method == 'POST'){
    commonResponse(res);
    res.end();
  }
}

let handleWeb = function(req, res){
  commonResponse(res)
  res.end();
}

http.createServer(handleApi).listen(4513);
http.createServer(handleWeb).listen(4514);

Select all the correct answers.

(multiple correct answers possible)

Easy 
5min
   


3. Input Event

Node.js Event handling Public New

Fill in the blanks in the following code so that handleInput is a listener for the "input" event and that stdin listener invokes the "input" event:

const events = require("events");
const emitter = new events.EventEmitter();
const stdin = process.openStdin();

const handleInput = function(input){
  console.log("Input is: ", input);
}
emitter.("input", handleInput);

stdin.addListener('data', d => {
  emitter.("input", d.toString());
});
Easy 
5min
   


If you feel ready, take one of our timed public Node.js Interview Questions tests:
  • HTML/CSS, Angular, TypeScript, Node.js, and SQL Online Test (Easy / Hard)
  • HTML/CSS, Angular, TypeScript, and Node.js Online Test (Easy / Hard)
  • HTML/CSS, JavaScript, Node.js, and SQL Online Test (Easy / Hard)
  • HTML/CSS, React, Node.js, and SQL Online Test (Easy / Hard)
  • HTML/CSS, React, and Node.js Online Test (Easy / Hard)
  • JavaScript and Node.js Online Test (Easy / Hard)
  • JavaScript, Node.js, and SQL Online Test (Easy / Hard)
Not exactly what you are looking for? Go to our For Jobseekers section.