Answer the question
In order to leave comments, you need to log in
How to create directories recursively?
What's the easy way to create nested directories?
Answer the question
In order to leave comments, you need to log in
https://www.npmjs.com/package/mkdirp - specific to your task
https://www.npmjs.com/package/fs-extra - extended fs
https://www.npmjs.com/package/shelljs - shell commands in unix style cross-platform
about a clean node, the modules are written on it, no one bothers to do it yourself,
we do it in a simple way, by calling the system command:
const cp = require('child_process');
const path = require('path');
const {promisify} = require('util');
const exec = promisify(cp.exec);
function mkdirp(dirPath) {
return (process.platform === 'win32'
? exec(`mkdir ${path.win32.resolve(dirPath)}`) // win версия рекурсивна по умолчанию
: exec(`mkdir -p ${path.posix.resolve(dirPath)}`)
);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question