I tried to run this small node test app but when I try to use the stat method from the fs module, it keeps on throwing the same error as - cannot read property 'isDirectory' of undefined
var http = require("http");
var fileSys = require("fs");
http.createServer(function(req, res) {
if(req.statusCode != 404) {
fileSys.readdir("templates", function(error, folders) {
if(!error) {
for (var i in folders) {
fileSys.stat(folders[i], function(error, stats) {
if(!error) {
res.writeHead("200", {"Content-type": "text/plain"});
res.end(stats.isDirectory());
} else {
console.log(error);
return;
}
});
}
} else {
console.log(error);
return;
}
});
}
}).listen(8080);
console.log("Server started.......");
console.log("Server running on loopback:8080 ;)");
then I ran the code twice with and without admin privileges but the problem still persists and the error shows up
Aucun commentaire:
Enregistrer un commentaire