var fs = require("fs"); if ( fs.existsSync("lib") ){ console.log("Directory already there"); } else { fs.mkdir("lib", function(error) { if (error) { console.log(error); } else { console.log("directory Created"); } } }