
Security News
Insecure Agents Podcast: Certified Patches, Supply Chain Security, and AI Agents
Socket CEO Feross Aboukhadijeh joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.
Make a directory and its parents if needed - Think
mkdir -p
[!TIP] You probably want the built-in
fsPromises.mkdir('…', {recursive: true})instead.
fsPromises.mkdir('…', {recursive: true})fs implementation.mkdirpmkdirp issuesfs.mkdir/mkdirSync recursive option in Node.js unless overriddennpm install make-dir
$ pwd
/Users/sindresorhus/fun
$ tree
.
import {makeDirectory} from 'make-dir';
const path = await makeDirectory('unicorn/rainbow/cake');
console.log(path);
//=> '/Users/sindresorhus/fun/unicorn/rainbow/cake'
$ tree
.
└── unicorn
└── rainbow
└── cake
Multiple directories:
import {makeDirectory} from 'make-dir';
const paths = await Promise.all([
makeDirectory('unicorn/rainbow'),
makeDirectory('foo/bar')
]);
console.log(paths);
/*
[
'/Users/sindresorhus/fun/unicorn/rainbow',
'/Users/sindresorhus/fun/foo/bar'
]
*/
Returns a Promise for the path to the created directory.
Returns the path to the created directory.
Type: string | URL
The directory to create.
Type: object
Type: integer
Default: 0o777
The directory permissions.
Type: object
Default: import fs from 'node:fs'
Use a custom fs implementation. For example graceful-fs.
Using a custom fs implementation will block the use of the native recursive option if fs.mkdir or fs.mkdirSync is not the native function.
mkdirp is a package with functionality similar to make-dir, allowing for the creation of directories and their parents if they don't exist. The main difference is that mkdirp has been around longer and was more widely used before Node.js introduced native support for recursive directory creation in version 10.12.0. make-dir, however, offers a more modern promise-based API, making it a better fit for asynchronous workflows.
fs-extra extends the Node.js built-in fs module, adding file system methods that aren't included in the standard library, such as recursive directory creation. While fs-extra includes functionality similar to make-dir, it's a more comprehensive package that offers a wide range of file system operations, making it a heavier dependency if directory creation is the only required feature.
FAQs
Make a directory and its parents if needed - Think `mkdir -p`
The npm package make-dir receives a total of 44,031,373 weekly downloads. As such, make-dir popularity was classified as popular.
We found that make-dir demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.

Security News
Tailwind Labs laid off 75% of its engineering team after revenue dropped 80%, as LLMs redirect traffic away from documentation where developers discover paid products.

Security News
The planned feature introduces a review step before releases go live, following the Shai-Hulud attacks and a rocky migration off classic tokens that disrupted maintainer workflows.