4

If I use fs.writeFile I get:

Error: ENOENT, No such file or directory

I think that's because the directories that houses the file doesn't exist.

Am I supposed to use fs.mkdir first or is there something else?

Thanks.

Harry
  • 52,711
  • 71
  • 177
  • 261

1 Answers1

2

Node.js lacks a recursive directory creator in the core API.

Someone is yet to make something equivalent to Perl's File::Path, but here's at least a recursive creator in Node:

https://github.com/isaacs/npm/blob/master/lib/utils/mkdir-p.js

Edit:
This is probably easier to use: https://github.com/bpedro/node-fs

entropo
  • 2,481
  • 15
  • 15