D
D
devalone2016-07-10 03:42:31
Node.js
devalone, 2016-07-10 03:42:31

nodejs. How to create a file based on the folder structure?

Let's say you need to create the file "/tmp/storage/28/08/2808c0dd765c2f0f486e0941d9da3544". Is it possible, using the built-in Nodejs tools, to create the entire folder structure if they don't exist? Or will you have to parse the regular string and call fs.exists and fs.mkdir for each folder?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Vapelnik, 2016-07-10
@devalone

Yes, you need to create each directory separately. if it's lazy then kind people wrote a module: https://github.com/substack/node-mkdirp

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question