1. Home
  2. Node
  3. Readdir

Read directory (readdir) is a method belonging to the Node native file system module (fs). reddir is an asynchronous method and it used a javascript promise to return an error or an array with a list of filenames located in the given directory.

#node#module
const fs = require('fs');

fs.readdir('./', function(err, files){
    console.log("--- FS INFO");
    if (err) console.log("Error: ", err);
    else console.log("Root: ", files);
});
copy
Full Node cheatsheet
NordVPN NordVPN