{"_id":"find-cache-directory","_rev":"4536780","name":"find-cache-directory","description":"Finds the common standard cache directory","dist-tags":{"latest":"6.0.0"},"maintainers":[{"name":"sindresorhus","email":""}],"time":{"modified":"2026-04-09T14:35:15.000Z","created":"2025-04-08T15:25:21.043Z","6.0.0":"2025-04-08T15:25:21.043Z"},"users":{},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"repository":{"type":"git","url":"git+https://github.com/sindresorhus/find-cache-directory.git"},"versions":{"6.0.0":{"name":"find-cache-directory","version":"6.0.0","description":"Finds the common standard cache directory","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/find-cache-directory.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"types":"./index.d.ts","default":"./index.js"},"sideEffects":false,"engines":{"node":">=20"},"scripts":{"test":"xo && ava && tsd"},"keywords":["cache","directory","caching","find","search"],"dependencies":{"common-path-prefix":"^3.0.0","pkg-dir":"^8.0.0"},"devDependencies":{"ava":"^6.2.0","del":"^8.0.0","tempy":"^3.1.0","tsd":"^0.31.2","xo":"^0.60.0"},"ava":{"workerThreads":false},"xo":{"rules":{"n/no-unsupported-features/node-builtins":"off"}},"_id":"find-cache-directory@6.0.0","gitHead":"7cc7f848ae24702ebb0a954f3a91ec3a78550163","types":"./index.d.ts","bugs":{"url":"https://github.com/sindresorhus/find-cache-directory/issues"},"homepage":"https://github.com/sindresorhus/find-cache-directory#readme","_nodeVersion":"23.6.1","_npmVersion":"10.9.2","dist":{"shasum":"6375d90b238b12c124c5150016b76adfdab3a26e","size":3040,"noattachment":false,"key":"/find-cache-directory/-/find-cache-directory-6.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/find-cache-directory/download/find-cache-directory-6.0.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/find-cache-directory_6.0.0_1744125920860_0.2550082092352126"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-04-08T15:25:21.043Z","publish_time":1744125921043,"_source_registry_name":"default","_cnpm_publish_time":1744125921043}},"readme":"# find-cache-directory\n\n> Finds the common standard cache directory\n\nThe [`nyc`](https://github.com/istanbuljs/nyc) and [`AVA`](https://avajs.dev) projects decided to standardize on a common directory structure for storing cache information:\n\n```sh\n# nyc\n./node_modules/.cache/nyc\n\n# ava\n./node_modules/.cache/ava\n\n# your-module\n./node_modules/.cache/your-module\n```\n\nThis 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:\n\n```\nrm -rf ./node_modules/.cache\n```\n\n## Install\n\n```sh\nnpm install find-cache-directory\n```\n\n## Usage\n\n```js\nimport findCacheDirectory from 'find-cache-directory';\n\nfindCacheDirectory({name: 'unicorns'});\n//=> '/user/path/node-modules/.cache/unicorns'\n```\n\n## API\n\n### findCacheDirectory(options?)\n\nFinds the cache directory using the given options.\n\nThe 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.\n\n#### options\n\nType: `object`\n\n##### name\n\n*Required*\\\nType: `string`\n\nShould be the same as your project name in `package.json`.\n\n##### files\n\nType: `string[]`\n\nAn 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.\n\n##### cwd\n\nType: `string`\\\nDefault `process.cwd()`\n\nThe directory to start searching for a `package.json` from.\n\n##### create\n\nType: `boolean`\\\nDefault `false`\n\nCreate the directory synchronously before returning.\n\n## Tips\n\n- To test modules using this package, set the `CACHE_DIR` environment variable to temporarily override the directory that is resolved.\n\n## Adopters\n\n- [`ava`](https://avajs.dev)\n- [`nyc`](https://github.com/istanbuljs/nyc)\n- [`storybook`](https://github.com/storybookjs/storybook)\n- [`babel-loader`](https://github.com/babel/babel-loader)\n- [`eslint-loader`](https://github.com/MoOx/eslint-loader)\n- [More…](https://www.npmjs.com/browse/depended/find-cache-dir)\n\n## Related\n\n- [env-paths](https://github.com/sindresorhus/env-paths) - Get paths for storing things like data, config, cache, etc\n","_attachments":{},"homepage":"https://github.com/sindresorhus/find-cache-directory#readme","bugs":{"url":"https://github.com/sindresorhus/find-cache-directory/issues"},"license":"MIT"}