How To Create Module | Web application Node Js | Tutorial For Beginner https://youtu.be/nXUdLhoxCbw Create Your Own Modules You can create your own modules, and easily include them in your applications. The following example creates a module that returns a date and time object: Example Create a module that returns the current date and time: exports.myDateTime = function () { return Date(); }; Use the exports keyword to make properties and methods available outside the module file. Save the code above in a file called "myfirstmodule.js" Include Your Own Module Now you can include and use the module in any of your Node.js files. Example Use the module "myfirstmodule" in a Node.js file: var http = require('http'); var dt = require('./myfirstmodule'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/html'}); res.write("The date and time are currently: " + dt.myDateTime()); res.end(); }).listen(8080); Notice that we use ./ to locate the module, that means that the module is located in the same folder as the Node.js file. Save the code above in a file called "demo_module.js", and initiate the file: Initiate demo_module.js: C:\Users\Your Name\node demo_module.js If you have followed the same steps on your computer, you will see the same result as the example: http://localhost:8080 Hello World Program | Web application Node Js | Tutorial For Beginner https://youtu.be/gDQ-jU5bo7w Software Installation | Node Js :- https://youtu.be/7gi6lgK-BIA Node Js Download Link:- https://nodejs.org/en/download Software Installation Playlist https://www.youtube.com/playlist?list=PLHeKsaIQNmlqvVEHF9mMfUPMCPtIjlARL #Subscribe the #Channel #Link :- #bansodetechsoluiotn #ajupgrading https://www.youtube.com/c/AjUpgradingBANSODETECHSOLUTION?sub_confirmation=1 IF any #Query or #Doubt #DM on #Instagram :- #bansode_ajay_2102 https://www.instagram.com/bansode_ajay_2102?r=nametag Whatsapp Channel Link https://whatsapp.com/channel/0029VaOllPkEKyZAoy7K791X
How To Create Module | Web application Node Js | Tutorial For Beginner https://youtu.be/nXUdLhoxCbw Create Your Own Modules You can create your own modules, and easily include them in your applications. The following example creates a module that returns a date and time object: Example Create a module that returns the current date and time: exports.myDateTime = function () { return Date(); }; Use the exports keyword to make properties and methods available outside the module file. Save the code above in a file called "myfirstmodule.js" Include Your Own Module Now you can include and use the module in any of your Node.js files. Example Use the module "myfirstmodule" in a Node.js file: var http = require('http'); var dt = require('./myfirstmodule'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/html'}); res.write("The date and time are currently: " + dt.myDateTime()); res.end(); }).listen(8080); Notice that we use ./ to locate the module, that means that the module is located in the same folder as the Node.js file. Save the code above in a file called "demo_module.js", and initiate the file: Initiate demo_module.js: C:\Users\Your Name\node demo_module.js If you have followed the same steps on your computer, you will see the same result as the example: http://localhost:8080 Hello World Program | Web application Node Js | Tutorial For Beginner https://youtu.be/gDQ-jU5bo7w Software Installation | Node Js :- https://youtu.be/7gi6lgK-BIA Node Js Download Link:- https://nodejs.org/en/download Software Installation Playlist https://www.youtube.com/playlist?list=PLHeKsaIQNmlqvVEHF9mMfUPMCPtIjlARL #Subscribe the #Channel #Link :- #bansodetechsoluiotn #ajupgrading https://www.youtube.com/c/AjUpgradingBANSODETECHSOLUTION?sub_confirmation=1 IF any #Query or #Doubt #DM on #Instagram :- #bansode_ajay_2102 https://www.instagram.com/bansode_ajay_2102?r=nametag Whatsapp Channel Link https://whatsapp.com/channel/0029VaOllPkEKyZAoy7K791X