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?
You don't say you want to do it recursively so I assume you only need direct children of the directory.
Sample code:
const fs = require('fs'); const path = require('path'); fs.readdirSync('your-directory-path') .filter((file) => fs.lstatSync(path.join(folder, file)).isFile());