explaingit

raszi/node-tmp

Analysis updated 2026-07-18 · repo last pushed 2026-05-27

773JavaScriptAudience · developerComplexity · 2/5MaintainedSetup · easy

TLDR

A Node.js library that creates uniquely named temporary files and directories, with automatic cleanup when your program exits.

Mindmap

mindmap
  root((node-tmp))
    What it does
      Creates temp files
      Creates temp dirs
      Automatic cleanup
    Tech Stack
      Node.js
      JavaScript
    Use Cases
      Image conversion staging
      Test suite scratch space
      Build pipeline staging
    Audience
      Node.js developers
      Test authors
      Build tool authors

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Save an uploaded file to a temp path, convert it, serve the result, then delete the temp file automatically.

USE CASE 2

Create a temporary directory for a test suite that disappears once the tests finish.

USE CASE 3

Stage intermediate files in a build tool or data pipeline without manually managing cleanup.

USE CASE 4

Generate a guaranteed-unique file or directory name without any risk of collision between processes.

What is it built with?

Node.jsJavaScript

How does it compare?

raszi/node-tmpgaearon/react-transform-hmrgaearon/todos
Stars773768785
LanguageJavaScriptJavaScriptJavaScript
Last pushed2026-05-272018-03-212020-06-10
MaintenanceMaintainedDormantDormant
Setup difficultyeasymoderateeasy
Complexity2/53/52/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

In plain English

When a program needs a scratchpad, somewhere to stash a file for a few seconds, process it, and throw it away, it needs a temporary file or folder. This library, called Tmp, handles that for applications built on Node.js. It creates uniquely named files and directories, gives your program the path to use them, and can optionally clean them up automatically when your program finishes. Under the hood, it uses random characters (via cryptography when available) to generate names, so there's virtually no chance of two parts of your program accidentally grabbing the same file. You can ask it for a temporary file, a temporary directory, or just a unique name without actually creating anything. It works asynchronously (your program keeps running while it waits) or synchronously (your program pauses until the file is ready). You can also customize things like file extensions, naming prefixes, and where on your computer the files get created. Who uses this? Any developer building a Node.js application that needs short-lived storage. For example, if you're building a tool that converts uploaded images from one format to another, you might save the original to a temp file, do the conversion, serve the result, then delete the temp file. Or if you're writing test suites, you might create a temporary directory, run tests against files inside it, and have it all disappear when the tests finish. It's also common in build tools and data pipelines that need a place to stage intermediate results. One notable feature is "graceful cleanup", a single call tells the library to automatically remove every temporary file and directory it created when your program exits, so you don't leave junk scattered across the system. You can also take manual control, choosing to keep files around or force-remove directories even if they still contain items. The project has been around long enough to be one of the most depended-upon packages in the Node.js ecosystem, and it recently dropped some older dependencies to stay lean.

Copy-paste prompts

Prompt 1
Show me how to use node-tmp to create a temporary file, write to it, and clean it up automatically when my script exits.
Prompt 2
Help me set up node-tmp's graceful cleanup so all temp files are removed when my Node.js program exits.
Prompt 3
Explain the difference between node-tmp's synchronous and asynchronous APIs for creating temp directories.
Prompt 4
Write a Node.js script using node-tmp that stages an uploaded image in a temp file before conversion.

Frequently asked questions

What is node-tmp?

A Node.js library that creates uniquely named temporary files and directories, with automatic cleanup when your program exits.

What language is node-tmp written in?

Mainly JavaScript. The stack also includes Node.js, JavaScript.

Is node-tmp actively maintained?

Maintained — commit in last 6 months (last push 2026-05-27).

How hard is node-tmp to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is node-tmp for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.