Answers for "read directory in nodejs"

3

read 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
3

how to get file name in directory node js

const fs = require('fs')

const dir = '/Users/flavio/folder'
const files = fs.readdirSync(dir)

for (const file of files) {
  console.log(file)
}
Posted by: Guest on October-16-2020
4

nodejs readdir

const fs = require("fs")
fs.readdir("./myfolder", (err, data) => {
	if(err) throw err
  	console.log(data)
})
Posted by: Guest on November-28-2020

Code answers related to "read directory in nodejs"

Code answers related to "Javascript"

Browse Popular Code Answers by Language