const path = require('path') //... //inside the `for` loop const stat = fs.lstatSync(path.join(dir, file))