Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

nodejs create folder if not exist

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

if (!fs.existsSync(dir)){
    fs.mkdirSync(dir);
}
Comment

how to check if a folder exist if not then create nodejs

//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 });
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to make a rectangle in javascript 
Javascript :: prototype pollution 
Javascript :: how to get all form values in javascript 
Javascript :: postman test check response status 
Javascript :: javascript how to check if object property exists 
Javascript :: convert date to millisecond in javascript 
Javascript :: js foreach .childern 
Javascript :: .env file node js 
Javascript :: json parse string 
Javascript :: convert base64 to image nodejs 
Javascript :: js string length 
Javascript :: concat array of objects javascript 
Javascript :: zoom out browser javascript 
Javascript :: jquery read query string 
Javascript :: js get object properties 
Javascript :: getusermedia example 
Javascript :: Facebook passport Oauth authenticate strategy 
Javascript :: where to place async in const function 
Javascript :: radio button set value in javascript 
Javascript :: javascript range of integers with spread 
Javascript :: js message timeout 
Javascript :: json to csv nodejs 
Javascript :: javascript sum array 
Javascript :: compose es6 
Javascript :: js insert item into array 
Javascript :: insert data from lambda to dynamodb 
Javascript :: order array of objects by id javascript 
Javascript :: website edit js 
Javascript :: datatables dynamically hide columns 
Javascript :: mongoose query if field exists where filed exists 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =