
Security News
Deno 2.6 + Socket: Supply Chain Defense In Your CLI
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.
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 27,878,548 weekly downloads. As such, find-cache-dir popularity was classified as popular.
We found that find-cache-dir demonstrated a healthy version release cadence and project activity because the last version was released less than 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.

Security News
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.

Security News
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.