Top 60+ Node.JS Interview Questions and answers

    1 Votes

16) Explain local installation of dependencies?

By default npm will install the dependency in the local mode. Here local mode refers to the package installation in node_modules directory lying in the folder where Node application is present. “require ()” is used to access the locally deployed packages.
17) Explain Package.JSON?

This will be present in the root directory of any Node module/application and will be used to define the properties of a package.

18) Explain “Callback hell”?
“Callback hell” will be referred to heavily nested callbacks which has become unreadable or unwieldly.
19) What are “Streams” in Node.JS?

“Streams” are objects which will let you read the data from source and write data to destination as a continuous process.

20) What you mean by chaining in Node.JS?

It’s a mechanism in which output of one stream will be connected to another stream and thus creating a chain of multiple stream operations.

21) Explain Child process module?

Child process module has following three major ways to create child processes –

  • spawn  - child_process.spawn launches a new process with a given command.
  • exec  - child_process.exec method runs a command in a shell/console and buffers the output.
  • fork - The child_process.fork method is a special case of the spawn() to create child processes.

22) Why to use exec method for Child process module?

“exec” method runs a command in a shell and buffers the output. Below is the command –

child_process.exec(command[, options], callback)

23) List out the parameters passed for Child process module?

Below are the list of parameters passed for Child Process Module –

child_process.exec(command[, options], callback)
  • command - This is the command to run with space-separated arguments.
  • options – This is an object array which comprises one or more following options –
  • cwd 
  • uid 
  • gid 
  • killSignal 
  • maxBuffer 
  • encoding 
  • env 
  • shell 
  • timeout 

callback – This is the function which is gets 2 arguments – stdout, stderr and error.

24) What is the use of method – “spawn()”?

This method is used to launch a new process with the given commands. Below is the method signature –

child_process.spawn(command[, args][, options])

25) What is the use of method – “fork()”?

This method is a special case for method- “spawn()” for creating node processes. The method signature –

child_process.fork(modulePath[, args][, options])

26) Explain Piping Stream?

This is a mechanism of connecting one stream to other and this is basically used for getting the data from one stream and pass the output of this to other stream.

27) What would be the limit for Piping Stream?

There will not be any limit for piping stream.

28) Explain FS module ?

Here FS stands for “File System” and fs module is used for File I/O. FS module can be imported in the following way –

var test = require("fs")

29) Explain “Console” in Node.JS?

“Console” is a global object and will be used for printing to stderr and stdout and this will be used in synchronous manner in case of destination is either file or terminal or else it is used in asynchronous manner when it is a pipe.

30) Explain – “console.log([data][, ...])” statement in Node.JS?

This statement is used for printing to “stdout” with newline and this function takes multiple arguments as “printf()”.

Page 2 of 4

Popular Videos


How to improve your Interview, Salary Negotiation, Communication & Presentation Skills.

Got a tip or Question?
Let us know

Related Articles

HTML/HTML5 Interview Questions and Answers
JQuery Interview Questions and Answers
Javascript Interview Questions and Answers
Top AngularJS Questions and Answers
Top 70 CSS Interview Questions and Answers
React JS Interview Questions and Answers