node js fs create multiple directories code example
Example: how to create multiple folders at once in node js
'use strict';
const { mkdir } = require('fs').promises;
(async function main() {
try {
const parent = '.';
const dirnames = ['pdfs', 'fonts', 'err/or', 'users'];
await Promise.all(
dirnames.map(dirname => mkdir(`${parent}/${dirname}`).catch(console.error))
);
// All dirs are created here or errors reported.
} catch (err) {
console.error(err);
}
})();