fs to fs-extra using node js
I tried to figure it out what changes i have to made if I am using var fse= require(&quot;fs-extra&quot;);
so my code will look like this


var fse=require("fs-extra");

async function checkFileLoc(folderPath, depth) {
  depth -= 1;
  let files = fse.readdirSync(folderPath);
  files = await Promise.all(
    files.map(async (file) =&gt; {
      const filePath = path.join(folderPath, file);
      const stats = fse.statSync(filePath);
      if (stats.isDirectory() &amp;&amp; depth &gt; 0) {
        return checkFileLoc(filePath, depth);
      } else if (stats.isFile()) return filePath;
      else return null;
    })
  );
  return files
    .reduce((all, folderContents) =&gt; all.concat(folderContents), [])
    .filter((e) =&gt; e != null);
}



I replaced my

var fs=require(&quot;fs&quot;); to var fse=require(&quot;fs-extra&quot;);
let files = await fs.readdir(folderPath); with let files = fs.readdirSync(folderPath);
const stats = await fs.stat(filePath); with const stats = fs.statSync(filePath);

now i am getting my desire output