Getting started with Node.js
Node.js is an open-source and cross platform JavaScript framework. It contains the V8 JavaScript engine, the standard library of packages, and some binaries.
Without creating a new thread for each request, a Node.js app operates in a single process. Node.js’ standard library includes a set of asynchronous I/O primitives that prevent JavaScript code from blocking, and libraries in Node.js are often created following non-blocking paradigms, thus blocking behavior is the exception rather than the norm.
Instead of blocking the thread and wasting CPU cycles waiting for a response, when Node.js conducts an I/O action, such as reading from the network, accessing a database, or accessing the filesystem, Node.js will resume the operations as the response comes back.
This allows Node.js to handle thousands of concurrent connections with a single server without having the burden of thread concurrency management, which may be a major source of bugs.
Ryan Dahl invented this amazing Node.js framework in 2009.
Installing Node.js
First of all, you have to download the Node.js installer from node web site. In this step you have to download it according to your operating system. You can visit the web site simply from this link. (https://nodejs.org/en/)
Secondly, you have to click the downloaded setup to begin the installation. Wizard will be appeared.
The node and npm binaries are added to your path when you install Node.js. That is to say, you can now use the node and npm commands.
You can just use Windows PowerShell or the Command Prompt to check if Node (and npm) were properly installed on your PC. You can type node -v
to check for the version of Node and npm -v
to check the version of npm you are using.
That’s pretty much it. You saw how to install Node and npm on Windows.
Advantages of using Node.js
Node.js is a user-friendly framework. There is an ability to use single programming language from one end of the application to the other end in this framework. Node.js has well build ‘npm’ package manager and its large number of reusable modules. One of a major advantage of node.js is that it allows you to create supercharged applications that display results in a matter of seconds. Because Node.js allows developers to create server-side code in JavaScript, we can write code for both the frontend and the backend with easily. You can use Node.js to build cross-platform real-time web applications using platforms like Electron and NW.js. This avoids the need to write separate code for different desktop versions such as Windows, Linux, and macOS.
Disadvantages of using Node.js
Major disadvantage in Node.js is reduces performance when handling Heavy Computing Tasks. To fix this, Node.js released the “worker threads” module in 2018, which allowed developers to run several threads at the same time. However, this technique does not fully prepare you to deal with CPU-bound computing difficulties. One of the most significant disadvantages is we have to do heavy code changes due to frequent API changes. And also, Node.js Asynchronous Programming Model. Hence, The callback might result in also known as callback hell. This directly impacts the performance and the quality of the code itself.
Without a doubt, Node.js is one of the most intriguing technologies in use today, and it has grown to become one of the most popular platforms for web apps, services, and desktop apps.