What are modules? 


As you would have noticed, when we set up our Node.js server, we imported 2 modules into our JavaScript file to help us.

What are modules? 

You can think of modules as the same as JavaScript libraries. They give us a set of functions we want to include in our application.

The cool thing is that Node.js has a set of built-in modules which you can use without any further installation. To include a module, use the require() function with the name of the module.


HTTP module require('http')


Node.js has a built-in module called HTTP, which allows Node.js to transfer data over the HyperText Transfer Protocol (HTTP).

As you have just seen in the example, we used the HTTP module to create an HTTP server that listens to server ports and gives a response back to the client (we used the createServer() method to create an HTTP server).


Querystring module require('querystring')


We also used the built-in querystring module.

The Node.js querystring module provides methods for parsing and formatting URL query strings.

It has various methods and properties (like decode() and encode()) but the one we used in our example was the parse() method. The parse() method is used to parse a URL query string into an object that contains the key and pair values of the query URL.