Ads

NodeJS Tutorial Day 2

Learning Objective: Let’s find rich Modules or Libraries that can help us to build NodeJS App easily. Here are the Node.js Built-in Modules.


For File Write/Read you need the following modules: (fs module)

var fs = require('fs');

fs.readFile('demofile.txt', 'utf8', function(err, data) {
  if (err) throw err;
  console.log(data);
});

To display some data in the browser use the following modules: (http module)

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.write('Hello World!');
  res.end();
}).listen(8080);

Want to read details about Operating System then use the following modules: (os module)

var os = require('os');
console.log("Platform: " + os.platform());
console.log("Architecture: " + os.arch());

Check out more NodeJS modules

Still looking for more modules here are 1000+ NodeJS Modules

Ads