How do you get a list of the names of all files present in a directory in Node.js?
getting all filenames in a directory with node.js [closed]
I can't find where in the documentation I can get all filenames in a directory.
The question linked and quoted above is a straightforward question about how one accomplishes a certain task in Node.js. It's poorly framed and worded, but, with a quick edit, it could be made a pretty standard question for the site.
Instead, it has been closed as off topic and locked with an explanation that seems based on a fundamental misreading of the question.
The explanation given for the close is that it is "off-topic because it is asking for recommendations".
It isn't asking for recommendations. It's simply asking how one can get all the filenames in a directory in Node.js. The reference to documentation isn't asking for a recommendation; it's stating that the user hasn't been able to turn up an answer elsewhere. All of that is pretty standard for Stack Overflow and has been since the beginning.
Rather than closing and locking the question, it could easily be edited along these lines:
How do you get a list of all the filenames in a directory in Node.js?
How do you retrieve a list of all filenames that exist in a particular directory in Node.js?
That would make it easily on-topic and directly in line with a majority of the questions asked on Stack Overflow.
So what gives? Why was it closed (six years later)? And why lock it, preventing other users from correcting the erroneous close?
To clarify: I don't think this is a recommendation question because it has a single, discrete, clear answer.
This question could be formatted as:
Q: "How do I get a list of filenames in a directory in Node.js?"
A: With fs.readdir() .. // further details
There are other options and possibilities, which many users have supplied and which are helpful. But the original asker wasn't asking for a list, they were simply asking for the answer.
javascript
tag....