Question:- What is npm? What is the main functionality of npm?
Answer:- npm stands for Node Package Manager. Following are the two main functionalities of npm: • Online repositories for node.js packages/modules which are searchable on search.nodejs.org • Command line utility to install packages, do version management and dependency management of Node.js packages.
Question:- What tools can be used to assure a consistent style in Node.js?
Answer:- Following is a list of tools that can be used in developing code in teams, to enforce a given style guide and to catch common errors using static analysis. • JSLint • JSHint • ESLint • JSCS
Question:- What is the difference between operational and programmer errors?
Answer:- Operational errors are not bugs, but create problems with the system like request timeout or hardware failure. On the other hand, programmer errors are actual bugs.
Question:- What is the difference between the global installation of dependencies and local installation of dependencies?
Answer:- • Global installation of dependencies is stored in /npm directory. While local installation of dependencies stores 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. • Globally deployed packages cannot be imported using require() in Node application directly. On the other hand, locally deployed packages are accessible via require(). • To install a Node project globally -g flag is used. C:Nodejs_WorkSpace>npm install express ?g • To install a Node project locally, the syntax is: C:Nodejs_WorkSpace>npm install express
Question:- What is the role of assert in Node.js?
Answer:- The Node.js Assert is a way to write tests. It provides no feedback when running your test unless one fails. The assert module provides a simple set of assertion tests that can be used to test invariants. The module is intended for internal use by Node.js, but can be used in application code via require (assert).
Question:- What are the streams in Node.js?
Answer:- The Streams are the objects that facilitate you to read data from a source and write data to a destination. There are four types of streams in Node.js: • Readable: This stream is used for reading operations. • Writable: This stream is used for write operations. • Duplex: This stream can be used for both reading and write operations. • Transform: It is a type of duplex stream where the output computes according to input.
Question:- What is event-driven programming in Node.js?
Answer:- In Node.js, event-driven programming means as soon as Node starts its server, it initiates its variables, declares functions and then waits for an event to occur. It is one of the reasons why Node.js is pretty fast compared to other similar technologies.
Question:- What is the difference between events and callbacks in Node.js?
Answer:- Although, Events and Callbacks look similar the differences lies in the fact that callback functions are called when an asynchronous function returns its result whereas event handling works on the observer pattern. Whenever an event gets fired, its listener function starts executing. Node.js has multiple in-built events available through the events module and EventEmitter class which is used to bind events and event listeners.
Question:- What is the Punycode in Node.js?
Answer:- The Punycode is an encoding syntax which is used to convert Unicode (UTF-8) string of characters to ASCII string of characters. It is bundled with Node.js v0.6.2 and later versions. If you want to use it with other Node.js versions, then use npm to install Punycode module first. You have to used require (Punycode) to access it.
Question:- What does Node.js TTY module contains?
Answer:- The Node.js TTY module contains tty.ReadStream and tty.WriteStream classes. In most cases, there is no need to use this module directly. You have to used require (tty) to access this module.
Question:- What are the main differences between operational and programmer errors?
Answer:- The most crucial difference between operational and programmer errors is that the operational errors are not bugs but problems with the system such as to request timeout or hardware failure. On the other hand, the programmer errors are actual bugs in the application.
Question:- What do you understand by an EventEmitter in Node.js?
Answer:- In Node.js, an EventEmitter is a class that includes all the objects capable of emitting events. This can be achieved by attaching named events that are emitted by the object using an eventEmitter.on() function. Thus whenever this object throws an event, the attached functions are invoked synchronously.
Question:- What is the difference between readFile and createReadStream in Node.js?
Answer:- In Node.js, there are two ways to read and execute files: readFile and CreateStream. • The readFile() process is a fully buffered process that returns the response only when the complete file is pushed into the buffer and is read. This process is called a memory-intensive process, and in the case of large files, the processing can be very slow. • On the other hand, the createReadStream() is a partially buffered process that treats the entire process as an event series. The entire file is split into chunks and then processed and sent back as a response one by one. After completing this step, they are finally removed from the buffer. Unlike the readFile process, the createReadStream process is effective for the processing of large files.
Question:- What is the concept of Punycode in Node.js?
Answer:- In Node.js, the concept of Punycode is used for converting one type of string into another type. Punycode is an encoding syntax used for converting Unicode (UTF-8) string of characters into a basic ASCII string of characters. Now, the hostnames can only understand the ASCII characters so, after the Node.js version 0.6.2 onwards, it was bundled up with the default Node package.
