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.

0

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

1 Comment

FYI, The link to mkdir-p.js is broken

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.