Node.js is server side runtime environment that lets us use JavaScript for development of backend applications
- Module is the only way to install any library in Node.js application
- Basically module in Node.js is a functionality which is organised in a single or multiple JavaScript file and can be reused throughout the Node.js application
- There are 3 categories of modules:
- Core modules: They are in-built and you can use them without any installation
- User defined modules: They are created by you and you can reuse them in rest of your application
- Node Package Manager: These include a group of Modules or packages, developed by other developers, which can be used in your application by installing them
- We usually include/install a library(module) using following syntax:
- ES5: var module = require('module_name')
- ES6: import {module} from ‘module_name’
- The require() function mentioned here returns an object, function, property or any other JavaScript type, depending on what is mentioned in module
I hope this clears your doubt:)
To know more about Node JS, It's recommended to join Node JS Course today.