Answers for "list all dir and file noejs"

3

Get List of all files in a directory in Node.js

const testFolder = './tests/';
const fs = require('fs');

fs.readdir(testFolder, (err, files) => {
  files.forEach(file => {
    console.log(file);
  });
});
Posted by: Guest on April-09-2021
0

nodejs get all folders in directory

const { readdirSync } = require('fs')

const getDirectories = source =>
  readdirSync(source, { withFileTypes: true })
    .filter(dirent => dirent.isDirectory())
    .map(dirent => dirent.name)
Posted by: Guest on October-03-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language