- This Node js tutorial is designed for beginners to help you learn Node.js step by step.
- All you need to do is follow this Node.js tutorial stepwise.
- Each step covers important topics related to Node.js.
This Node.js tutorial is divided into 7 steps. We expect you to follow this step by step. We are going to cover the following topics in this Node.js tutorial:.
Step 1: Node js basic concepts – Libuv, Event loop, Libev. Step 2: Building a Simple Web Server in Node.js.
Step 3: Node.js modules and NPM. Step 4: File system module. Step 5: Express framework.
Step 6: Databases – MySQL, MongoDB, PostgreSQL and Redis. Step 7: Deployment – deploying applications in Digitalocean Server. After reading this Node.js tutorial, you should be able to build applications using Node.js and deploy it on a cloud server.
Step 4: File system module.
Deploy your application
Step 5: Express framework
Step 1: Node js basic concepts
The developers of V8 used the just-in-time (JIT) compiler methodology to improve the code compilation time.
It is open-source and is used in the Node.js and MongoDB project.
An Express application
The libuv library is a cross-platform library that provides an asynchronous I/O facility by enabling an event-driven I/O operation.
The libuv library creates a thread for the I/O operation (file, DNS, HTTP, and so on) and returns a callback.
Step 7: Deploying Node application to a Cloud Server
Event driven I/O – libuv
As I mentioned earlier, libuv assigns threads for the I/O operation and returns the callback to the callee program.
Therefore, Node.js internally creates threads for I/O operation; however, it gives the programmer access to a single runtime thread.
Running Hello World
When you make an HTTP request to the web server built using Node.
It creates the libuv thread and is ready to accept another request.
Working of libuv – the core of Node.js
The libuv library provides the following important core features:.
Fully featured event loop.
How Event Loop Works
Thread and synchronization primitives.
Asynchronous TCP and UDP sockets.
The libuv library internally uses another famous library called libeio, which is designed for threading and asynchronous I/O events and libev, which is a high-performance event loop.
Therefore, you can treat libuv as a package wrapper for both of them.
The multi-threading approach provides parallelism using threads so that multiple programs can simultaneously run.
it is really difficult to handle concurrency and deadlock in a multi-threading system.