Answers for "create a directory in javascript"

6

nodejs make directory

var fs = require('fs');
var dir = './tmp';
if (!fs.existsSync(dir)){
    fs.mkdirSync(dir);
}

// or if complains about existence and nesting doesn't matter:

var shell = require('shelljs');
shell.mkdir('-p', 'root/parent/tmp');
Posted by: Guest on March-30-2020
1

how to make directory in javascript

const fs = require('fs');

// directory path
const dir = './views';

// create new directory
fs.mkdir(dir, (err) => {
    if (err) {
        throw err;
    }
    console.log("Directory is created.");
});
Posted by: Guest on June-01-2021

Code answers related to "create a directory in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language