What is Node.js?
The Composition of Node.js
The other great benefit of Node.js is that it uses an input/output model that is non-blocking and instead, event driven. Input/output means anything from reading and writing files to making HTTP requests.
A blocking input/output model makes multi-tasks inefficient because it is a single-threaded event loop. This means that if you were to request data for two users to be printed on the screen, it would first initiate the request for the first user and then initiate the request for second user once the first user’s data is printed on the screen. A non-blocking I/O eliminates the need to wait for the first user’s data to be printed and instead takes and runs both requests at the same time, making it perfect for multi-tasks.
Node.js Package Ecosystem
Node.js also has the largest ecosystem of open source libraries, known as the Node.js package ecosystem (npm). You can find solutions to most of your problems that will make app development faster and more efficient.
Require is a function that does three things. It loads modules with Node.js and HTTP from the Node.js API, it installs libraries from npm and it allows you to set requirements for only your own files and to modularize the project.
Node modules are blocks of code that don’t impact other code unless written to and can be reused. You are able to use them in various applications and you can write your own. There are also built-in modules that you can use without any installation.