Answers for "node fs create folder and file if not exists"

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

nodejs fs create file if not exists

fs.exists(filename, function(exists) {
  if(exists) {
    // Create a file
  }
  else {
    console.log("Deny overwrite existing", filename);
  }
});
Posted by: Guest on February-19-2021

Code answers related to "node fs create folder and file if not exists"

Code answers related to "Javascript"

Browse Popular Code Answers by Language