var fs = require('fs');
var dir = './tmp';
if (!fs.existsSync(dir)){
fs.mkdirSync(dir);
}
//For individual dirs:
var {existsSync, mkdirSync} = require('fs');
var dir = './tmp';
if (!existsSync(dir)){
mkdirSync(dir);
}
//For nested dirs:
var {existsSync, mkdirSync} = require('fs');
var dir = './tmp/but/then/nested';
if (!existsSync(dir)){
mkdirSync(dir, { recursive: true });
}