Node.js includes three types of modules:
1. Core Modules
3. Third Party Modules
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:
Now our application has access to the HTTP module, and is able to create a server:
Create Your Own Modules
We can create our own modules, and easily include them in our applications. Create a module that returns the current date and time:
Use the exports keyword to make properties and methods available outside the module file. Save above code in a file named as "myModule.js"
Include our Own Module
We can include the module by using the require function in any of our Node.js files.