0

I want to create directory structure ./a/b/file.js. Here 'a', 'b' are directories and 'file.js' is created within 'a', 'b'. At once I want to create this file structure.

Let me know how to do this?

file.js

let fs = require('fs');
 let path4 = require('path');   
module.exports = {
    test
}

function test () {
let filepath = path4.resolve(process.env.TEMP + path4.sep + "A" + path4.sep  + "B" + path4.sep +  "file.js"); 
  if( fs.existsSync(filepath)) {
    console.log("file already exist");
  } else {
   fs.mkdirSync(filepath);
  }
}

But when I run this script , I see this error Error: ENOENT: no such file or directory,

karansys
  • 2,449
  • 7
  • 40
  • 78

0 Answers0