Answers for "how to create multiple folders at once in node js"

0

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);
  }
})();
Posted by: Guest on September-02-2020

Code answers related to "how to create multiple folders at once in node js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language