I\'m trying to get a list of the names of all the files present in a directory using Node.js. I want output that is an array of filenames. How can I do this?
This will work and store the result in test.txt file which will be present in the same directory
fs.readdirSync(__dirname).forEach(file => { fs.appendFileSync("test.txt", file+"\n", function(err){ }) })