Answers for "create directory if not node js"

0

nodejs create folder if not exist

var fs = require('fs');
var dir = './tmp';

if (!fs.existsSync(dir)){
    fs.mkdirSync(dir);
}
Posted by: Guest on July-02-2021
0

node js create or check directory

//Synchronously
fs.mkdirSync('./path/to/my/directory', { recursive: true })

//Asynchronously
await fs.promise.mkdir('./path/to/my/directory', { recursive: true })
Posted by: Guest on August-09-2021

Code answers related to "create directory if not node js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language