Node provides a set of APIs to interact with the operating system. If you want to read all the files in a directory you could use the fs
module. Hereβs how:
const fs = require('fs').promises;
fs.readdir('path/to/dir').then((files) => {
files.forEach((file) => console.log(file));
});
Note that the calls to the file system are asynchronous, to handle this we used the promisified APIs, but the callback-based ones also exist