This function encapsulates the logic necessary to create a full directory tree (recursively). Since the recursive flag was only added to the mkdir function from the native fs package on version 10.x, I created this function to fill this gap
npm install --save mkdirt
const mkdirt = require('mkdirt');
async function main() {
await mkdirt('x/y/z', 0o775);
}
main();