How can I count the number of files in a directory using nodejs with just plain JavaScript or packages? I want to do something like this:
nodejs
How to count the n
Using fs, I found retrieving the directory file count to be straightforward.
const fs = require('fs'); const dir = './directory'; fs.readdir(dir, (err, files) => { console.log(files.length); });