0

How can I create a nested chain of non existing directories?

import { writeFileSync, mkdir } from 'fs'
const filename = 'EEE/TTT/moish.txt'
mkdir(filename, { recursive: true }, (err) => {});
writeFileSync(filename, "Hello World");

The sub directories EEE and EEE/TTT do not exist.

$ npx tsc ./main.ts     
$ node ./main.js
node:internal/fs/utils:348
    throw err;
    ^

Error: ENOENT: no such file or directory, open 'EEE/TTT/moish.txt'
OrenIshShalom
  • 5,974
  • 9
  • 37
  • 87

0 Answers0