fs check if directory exists code example
Example 1: how to check if a folder exists in node js
const fs = require("fs")
fs.access("./directory-name", function(error) {
if (error) {
console.log("Directory does not exist.")
} else {
console.log("Directory exists.")
}
})
Example 2: fs check if dir is dir
fs.lstatSync(path_string).isDirectory()