
Product
Socket for Jira Is Now Available
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.
find-cache-dir
Advanced tools
Finds the common standard cache directory
The nyc and AVA projects decided to standardize on a common directory structure for storing cache information:
# nyc
./node_modules/.cache/nyc
# ava
./node_modules/.cache/ava
# your-module
./node_modules/.cache/your-module
This module makes it easy to correctly locate the cache directory according to this shared spec. If this pattern becomes ubiquitous, clearing the cache for multiple dependencies becomes easy and consistent:
rm -rf ./node_modules/.cache
npm install find-cache-dir
import findCacheDirectory from 'find-cache-dir';
findCacheDirectory({name: 'unicorns'});
//=> '/user/path/node-modules/.cache/unicorns'
Finds the cache directory using the given options.
The algorithm checks for the CACHE_DIR environmental variable and uses it if it is not set to true, false, 1 or 0. If one is not found, it tries to find a package.json file, searching every parent directory of the cwd specified (or implied from other options). It returns a string containing the absolute path to the cache directory, or undefined if package.json was never found or if the node_modules directory is unwritable.
Type: object
Required
Type: string
Should be the same as your project name in package.json.
Type: string[]
An array of files that will be searched for a common parent directory. This common parent directory will be used in lieu of the cwd option below.
Type: string
Default process.cwd()
The directory to start searching for a package.json from.
Type: boolean
Default false
Create the directory synchronously before returning.
find-cache-dir, set the CACHE_DIR environment variable to temporarily override the directory that is resolved.cache-manager is a more general-purpose caching framework that supports multiple storage backends and provides a flexible API for caching. It is not specifically designed for finding cache directories but can be used to manage cache data in a variety of contexts.
mkdirp is a package that allows you to create a new directory and its parent directories if they do not exist. While it does not provide cache directory finding capabilities, it can be used in conjunction with find-cache-dir to ensure that the cache directory is created.
tmp is a utility for creating temporary files and directories. It can be used to create temporary cache directories, but unlike find-cache-dir, it does not find or manage persistent cache directories across runs.
FAQs
Finds the common standard cache directory
The npm package find-cache-dir receives a total of 40,071,415 weekly downloads. As such, find-cache-dir popularity was classified as popular.
We found that find-cache-dir demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.