tmp
Temporary file and directory creation library for Node.js. Creates temporary files and directories in the OS temp directory with unique names, automatic cleanup (on process exit or explicit), and configurable prefix/suffix/extension. Used in testing, file processing pipelines, and any scenario requiring secure temporary file handling. Simpler alternative to writing your own os.tmpdir() + crypto.randomBytes() logic.
Score Breakdown
⚙ Agent Friendliness
🔒 Security
Temp files in OS temp directory may be world-readable on some systems. For sensitive temp data, use chmod after creation. Cleanup is critical to prevent sensitive data leakage.
⚡ Reliability
Best When
You need simple, reliable temporary file/directory creation with automatic cleanup in Node.js scripts, tests, or processing pipelines.
Avoid When
You need cross-process temp file sharing or cloud-based temp storage.
Use Cases
- • Create temporary files for test fixtures that need to be cleaned up after tests
- • Write intermediate processing artifacts to temp files during multi-step file transformation pipelines
- • Generate temporary directory for file extraction, processing, and cleanup in CI/CD scripts
- • Create temp files for subprocess communication (passing large data to CLI tools via file arguments)
- • Safe temporary file handling in upload processing — write to temp, process, move to permanent storage
Not For
- • Long-lived files that need persistence — use regular file I/O for permanent files
- • High-security temporary data — OS temp dir may have permissive permissions; use secure tempfile creation for sensitive data
- • Cloud-based file temp storage — tmp uses local filesystem; use cloud storage for cross-instance temp files
Interface
Authentication
No authentication — local file system utility.
Pricing
Fully free, MIT licensed.
Agent Metadata
Known Gotchas
- ⚠ Cleanup with unsafeCleanup: true required for non-empty temp directories — default cleanup only removes empty directories; data files must be cleaned explicitly
- ⚠ Process exit cleanup requires GracefulCleanup registration — call tmp.setGracefulCleanup() at startup to ensure temp files are deleted on SIGTERM/SIGINT
- ⚠ Synchronous API (tmp.fileSync()) blocks event loop — use async API (tmp.file()) in server applications and event-driven code
- ⚠ OS temp directory location varies — /tmp on Linux/macOS, C:\Users\...\AppData\Local\Temp on Windows; don't hardcode temp paths
- ⚠ Temp file ownership: files are created with current process permissions — in multi-user scenarios, ensure temp files have restrictive permissions for sensitive data
- ⚠ tmp package is minimally maintained — consider tempfile (sindresorhus) or tempy for ESM-first modern alternatives
Alternatives
Full Evaluation Report
Comprehensive deep-dive: security analysis, reliability audit, agent experience review, cost modeling, competitive positioning, and improvement roadmap for tmp.
AI-powered analysis · PDF + markdown · Delivered within 30 minutes
Package Brief
Quick verdict, integration guide, cost projections, gotchas with workarounds, and alternatives comparison.
Delivered within 10 minutes
Score Monitoring
Get alerted when this package's AF, security, or reliability scores change significantly. Stay ahead of regressions.
Continuous monitoring
Scores are editorial opinions as of 2026-03-06.