Create own module in node js

Create own module in node js

We can write anything as you want in my_module.js file.

var http = require('http');
var dt = require('./my_module');

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);

Leave a Reply