Welcome to Node.js Tutorial – Following these lucid tutorials helps you learn basic understanding of Node.js. With the progression of your learning, more advanced concepts to program and build server side applications and networking applications are provided.
An introduction to Node.js
Node.js if free to use and is an open source server framework. Node.js runs on various platforms and some of them are Linux, Unix, Windows, Mac OS X, etc.
- Non-blocking I/O model
To appreciate the features of Node.js and how it revolutionized the server side applications in terms of resource usage and event handling, we might need to take a sneak peak into the traditional model of web servers. And know how Node.js fill the performance voids.
In a traditional web server, when a web-client (browser or an application) makes a request, server takes the request and waits for the response to be prepared by file system/database/any other resource. Consider that your web service has become popular and number of web-client requests hitting the server is increasing day by day. But if you observe, the server is serving one request at a time and while the file-system/database is preparing the response, the server is being idle, instead of taking requests from other customers. Node.js exploits this idle time with its event-driven framework. That is after taking a request, the server tries to prepare the response. And if there is any resource (file-system/database/etc) involved to prepare the response, server is let free and is informed through events when the response is ready. Mean while, instead of being idle during this time, server takes requests from other clients. When a response for a client is ready, an event is generated to let the server know the response is ready, which is in turn served to clients.
Programming Node.js Applications
Following are some of the capabilities of Node.js:
- Node.js can dynamically generate content and present it to web clients
- Node.js can do file operations like read, write, update, delete, etc.
- Node.js can collect data from clients through forms.
- Node.js can connect to various databases like MySQL, MongoDB, etc., and perform respective DB operations.
- Node.js has builtin JSON module to work with JSON files.
Node.js Production Ready
Currently Node.js v8.x is the latest Long Term Supported version. So, most of the examples you come across in this tutorial are tried out on Node.js v8.x.
Node.js Use Cases
Following are some of the notable use cases that can take advantage of the Node.js Event driven model.
- Low latency provided by Node.js makes it suitable for Real-time applications like instant messaging, online-gaming and collaborative applications like Google Docs etc.
- Doing tasks asynchronously makes Node.js scale for a much higher traffic.
- Node.js can scale horizontally using its cluster mode. So, if you are looking for a scalable web application, Node.js is there.
Following are some of the limitations of Node.js
- Node.js is not a good choice for applications that do heavy computation. This is because incoming requests are blocked during computation tasks that take relatively long time.
- Security provided by many of npm packages are not promising, even though core Node.js is quite stable. You may have to depend on third party tools to evaluate a package for any known vulnerabilities before using it in your application.
Node.js Tutorial Index
Following is the list of tutorials that are well explained with simplified examples to learn Node.js easily.
- Install Node.js
- Node.js Modules
- Node.js HTTP Module
- Node.js package.json
- Node.js FS (File System)
- Node.js NPM (Node Package Manager)
- Node.js Events
- Node.js Request module
- Node.js MySQL module
- Node.js MySQL Overview
- Node.js MySQL Connect DATABASE – Node.js Tutorial to connect to your MySQL Database.
- Node.js MySQL SELECT FROM query – Node.js Tutorial to demonstrate SELECT FROM with examples.
- Node.js MySQL WHERE query – Node.js Tutorial for MySQL WHERE query with examples.
- Node.js MySQL ORDER BY query – Node.js Tutorial for MySQL ORDER BY query with examples.
- Node.js MySQL INSERT INTO query – Node.js Tutorial for MySQL INSERT INTO query with examples.
- Node.js MySQL DELETE FROM – Node.js Tutorial for MySQL DELETE FROM query with examples.
- Node.js MySQL Result Object
- Node.js MongoDB
- Node.js JSON
- Node.js Examples