Hi All, Welcome back to NodeJS tutorial course. I hope you all have watched my previous sessions which
explains different concepts of nodejs and live coding examples. If not, below are the links -
Node.js - Section 1 Introduction & Setup - • Node.js | Section 1 | Introduction & ...
Node.js - Section 2 Architecture & Features - • Node.js | Section 2 | Architecture & ...
Node.js - Section 3 V8 Engine & First Example - • Node.js | Section 3 | V8 Engine & Fir...
Nodejs - Section 4 Globals & Live Examples - • Nodejs | Section 4 | Globals & Live E...
Nodejs - Section 5 REPL Console - • Nodejs | Section 5 | REPL Console | N...
Node.js - Section 6 Nodejs Basics - • Node.js | Section 6 | Nodejs Basics |...
In this video i am going to explain you all about nodejs modules, its different types and how to use it. Will also be showing live example on how to use them.
Modules-
Module in Node.js is a simple or complex functionality
organized in single or multiple JavaScript files
which can be reused throughout the Node.js application.
Each module in Node.js has its own context,
so it cannot interfere with other modules or pollute global scope.
Also, each module can be placed in a separate .js file under a separate folder.
Node.js implements CommonJS modules standard.
CommonJS is a group of volunteers who define JavaScript standards
for web server, desktop, and console application.
Node.js Module Types--
Core Modules
Local Modules
Third Party Modules
Core Modules -
Node.js is a light weight framework. The core modules include bare minimum functionalities of Node.js.
Local Module -
Local modules are modules created locally in your Node.js application.
These modules include different functionalities of your application in separate files and folders.
You can also package it and distribute it via NPM, so that Node.js community can use it.
Loading Local Module -
To use local modules in your application, you need to load it using require() function in the same way as core module.
Export Module in Node.js--
The module.exports is a special object which is included in every JavaScript .
Live examples are available in video