mkdirp

Recursive directory creation for Node.js (mkdir -p equivalent). Cross-platform solution for creating nested directory structures that may not exist. Modern versions (v3+) use Node.js native fs.mkdir({ recursive: true }) with a thin wrapper. Also provides a CLI bin for use in npm scripts.

Evaluated Mar 06, 2026 (0d ago) v3+
Homepage ↗ Repo ↗ Developer Tools nodejs mkdir recursive cross-platform filesystem build
⚙ Agent Friendliness
68
/ 100
Can an agent use this?
🔒 Security
96
/ 100
Is it safe for agents?
⚡ Reliability
84
/ 100
Does it work consistently?

Score Breakdown

⚙ Agent Friendliness

MCP Quality
--
Documentation
88
Error Messages
82
Auth Simplicity
100
Rate Limits
100

🔒 Security

TLS Enforcement
100
Auth Strength
100
Scope Granularity
100
Dep. Hygiene
90
Secret Handling
90

Path traversal risk if user input is passed without validation. Always sanitize paths before creating directories.

⚡ Reliability

Uptime/SLA
92
Version Stability
82
Breaking Changes
75
Error Recovery
88
AF Security Reliability

Best When

Cross-platform npm scripts and build tools needing recursive directory creation.

Avoid When

Targeting Node.js 12+ — native fs.mkdir({ recursive: true }) is sufficient without a dependency.

Use Cases

  • Create nested output directories in build scripts: mkdirp('dist/assets/images') creates all intermediate directories
  • Ensure directory exists before writing files in Node.js scripts without explicit existence checks
  • Use in npm scripts for cross-platform mkdir -p behavior: "setup": "mkdirp dist logs tmp"
  • Programmatically create directory trees in Node.js tools and generators
  • Replace platform-specific shell mkdir -p with cross-platform Node.js equivalent

Not For

  • Modern Node.js 12+ projects where fs.mkdir(path, { recursive: true }) is available — mkdirp is a thin wrapper today
  • Complex file system operations — use fs-extra for copy/move/ensureDir comprehensive file system utilities
  • Security-sensitive directory creation — validate paths before calling mkdirp to prevent path traversal

Interface

REST API
No
GraphQL
No
gRPC
No
MCP Server
No
SDK
Yes
Webhooks
No

Authentication

Methods: none
OAuth: No Scopes: No

Build tool — no auth needed.

Pricing

Model: open_source
Free tier: Yes
Requires CC: No

ISC licensed open source library.

Agent Metadata

Pagination
none
Idempotent
Full
Retry Guidance
Not documented

Known Gotchas

  • mkdirp v3 is ESM-only — CommonJS projects must use mkdirp v2 or native fs.mkdir({ recursive: true })
  • mkdirp returns undefined (not the path) if the directory already exists — check return value only when you need the first-created path
  • mkdirpSync is available for synchronous use — async mkdirp() is preferred but sync version exists for compatibility
  • Windows path separators work correctly but paths with spaces should be quoted in CLI usage
  • Permission errors are not retried — if directory creation fails due to permissions, the error is thrown immediately
  • mkdirp does not validate path safety — callers must sanitize paths to prevent creating unintended directory structures

Alternatives

Full Evaluation Report

Detailed scoring breakdown, competitive positioning, security analysis, and improvement recommendations for mkdirp.

$99

Scores are editorial opinions as of 2026-03-06.

5210
Packages Evaluated
26151
Need Evaluation
173
Need Re-evaluation
Community Powered