Returns the system cache directory for a given app name, or falls back to a predictable temporary directory. Version 1.0.0 is stable with no known release cadence. Alternatives like 'cache-directory' require optional dependencies (e.g., osx-tmpdir) and may fail entirely; this package always returns a writable path. It does not create the directory, only provides the path. The temp fallback is non-random, allowing cache sharing across processes. Lightweight, no dependencies, supports Node.js only.
npm install cache-or-tmp-directoryNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Gets the cache directory for 'myApp' and shows how to create it (package does not create directories).
Use fs.mkdirSync(dir, { recursive: true }) after getting the path.If you need unique temp directories, use a library like tmp or add randomness manually.
Use import or dynamic import() instead of require.
Set XDG_CACHE_HOME environment variable explicitly if needed.
import cacheOrTmpDir from 'cache-or-tmp-directory'
Manually create the directory with fs.mkdirSync(dir, { recursive: true }).Upgrade to webpack 5 or use a bundler that supports package.json exports.
No dependency data recorded yet.