mkdirp
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
The "mkdirp" package is used in Node.js to recursively create new directories, similar to how the mkdir -p
function works in UNIX systems. This is a hybrid module, meaning you can import or require it. As a modern API, it aims to have zero bugs though acknowledges that a few may be missed.
To use the "mkdirp" package, you first need to either import it using import { mkdirp } from 'mkdirp'
or require it using const { mkdirp } = require('mkdirp')
. The returned value is a Promise that resolves to the first directory created. For instance:
import { mkdirp } from 'mkdirp'
// return value is a Promise resolving to the first directory created
mkdirp('/tmp/foo/bar/baz').then(made =>
console.log(`made directories, starting with ${made}`)
)
If you prefer not to use promises, the .sync
function is available:
import { mkdirp } from 'mkdirp'
// return value is the first directory created
const made = mkdirp.sync('/tmp/foo/bar/baz')
console.log(`made directories, starting with ${made}`)
This ensures that the directories /tmp/foo/bar/baz
now exist.
The documentation for "mkdirp" can be found within the README of the package's GitHub page. This page includes in-depth explanations of all the methods provided by the package, example usage codes, CLI details, and tips for choosing a recursive mkdir
implementation. The URL for the package's GitHub page is: https://github.com/isaacs/node-mkdirp
.