Nodejs: trying to make a folder in a directory giving error no such files?

Viewed 39

I am trying to make a directory with help of node.js it is giving me error Error: ENOENT: no such file or directory, mkdir '../regionalprocess/20220906/text'

I am trying to achieve is -

  1. first go to regionalprocess folder
  2. then create a folder with value of ${directorycreating[1]
  3. and in ${directorycreating[1] create a folder text

I am trying to make a directory in regionalprocess folder with name of ${directorycreating[1] (this has some value) and in ${directorycreating[1] a folder name text

while creating folder with value ${directorycreating[1] this will work fine with below snippet code -

var dir = ../regionalprocess/${directoryCreating[1]};

but if I am trying to create a folder in ${directorycreating[1] with name text it is giving me an error

     var dir = `../regionalprocess/${directoryCreating[1]}/text`;

      if (!fs.existsSync(dir)) {
        fs.mkdirSync(dir);
        console.log("file created " + dir);
      } else {
        console.log("Error creating directory because it already exists");
      } 

so, exactly I am trying to create a directory in regionalprocess with name ${directoryCreating[1]} value and in this value I need to create text folder

regionalprocess + ${directoryCreating[1]} + text

0 Answers
Related