The above code imports fs module. The fs.stat(path, callback) method takes two arguments – the path to the file or directory and a callback function. Since fs.stat() is an asynchronous function, you have to pass a callback function to be executed when it finishes. The callback takes two arguments – err and stats which will be set by the fs.stat() method. The stats object has a stats.isDirectory() method that can be used to check for directories.

Most basic tasks can be performed by using just the core modules. For more advanced tasks, you can use a third-party module or write your own. Many frameworks are also available for rapid development like Express.js, Meteor, Hapi.js, Socket.io