{"id":44954,"library":"find-cache-directory","title":"find-cache-directory","description":"Finds the common standard cache directory (e.g., ./node_modules/.cache) across projects. Version 6.0.0 is the latest stable release, with a yearly release cadence. This package is part of a shared spec adopted by AVA, nyc, and others. Unlike generic cache path utilities (like env-paths), it relies on a package.json discovery algorithm and respects the CACHE_DIR environment variable. Ship TypeScript type definitions and requires Node.js >= 20.","status":"active","version":"6.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/sindresorhus/find-cache-directory","tags":["javascript","cache","directory","caching","find","search","typescript"],"install":[{"cmd":"npm install find-cache-directory","lang":"bash","label":"npm"},{"cmd":"yarn add find-cache-directory","lang":"bash","label":"yarn"},{"cmd":"pnpm add find-cache-directory","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM-only since v5; CommonJS require will fail with Module not found. Use dynamic import() if needed.","wrong":"const findCacheDirectory = require('find-cache-directory')","symbol":"findCacheDirectory","correct":"import findCacheDirectory from 'find-cache-directory'"},{"note":"The module uses a default export, not named. Named import will result in undefined.","wrong":"import { findCacheDirectory } from 'find-cache-directory'","symbol":"default export","correct":"import findCacheDirectory from 'find-cache-directory'"},{"note":"TypeScript types are exported; use import type for type-only imports.","wrong":"","symbol":"type import","correct":"import type { Options } from 'find-cache-directory'"}],"quickstart":{"code":"import findCacheDirectory from 'find-cache-directory';\n\nconst cacheDir = findCacheDirectory({\n  name: 'my-app',\n  create: true // creates directory if not exists\n});\n\nif (cacheDir) {\n  console.log(`Cache directory: ${cacheDir}`);\n} else {\n  console.log('Could not determine cache directory');\n}","lang":"typescript","description":"Finds and optionally creates the cache directory for a project named 'my-app'."},"warnings":[{"fix":"Use import or dynamic import('find-cache-directory').","message":"v5 dropped CommonJS support; require() will fail.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Upgrade Node.js or use v4.x (last CJS version).","message":"v6 requires Node.js >= 20.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Avoid thunk; use `create: true` on options object.","message":"Options `thunk` and `create` were removed in v4; use `create: true` directly.","severity":"deprecated","affected_versions":">=4.0.0 <5.0.0"},{"fix":"Set CACHE_DIR to an absolute path string to override.","message":"If `CACHE_DIR` env var is set to 'true', 'false', '1', or '0', it is ignored and falls back to normal resolution.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'/node_modules/.cache':12 '20':71 '6.0.0':16 'across':13 'adopt':35 'algorithm':56 'ava':37 'cach':3,9,43,60,73,75 'cadenc':26 'common':7 'definit':67 'dir':61 'directori':4,10,74 'discoveri':55 'e.g':11 'env':48 'env-path':47 'environ':62 'find':2,5,76 'find-cache-directori':1 'generic':42 'javascript':72 'latest':19 'like':46 'node.js':70 'nyc':38 'other':40 'packag':28 'package.json':54 'part':30 'path':44,49 'project':14 'releas':21,25 'reli':51 'requir':69 'respect':58 'search':77 'share':33 'ship':64 'spec':34 'stabl':20 'standard':8 'type':66 'typescript':65,78 'unlik':41 'util':45 'variabl':63 'version':15 'year':24","created_at":"2026-06-07T12:52:39.663228+00:00","updated_at":"2026-06-07T12:52:39.663228+00:00","problems":[{"fix":"Use `import findCacheDirectory from 'find-cache-directory'` or use dynamic `import('find-cache-directory')`","cause":"CommonJS require() used with ESM-only package","error":"Module not found: Error: Can't resolve 'find-cache-directory'"},{"fix":"Use `import findCacheDirectory from 'find-cache-directory'` (no curly braces)","cause":"Tried to use named import instead of default import","error":"findCacheDirectory is undefined"},{"fix":"Use ESM import syntax","cause":"Incorrect import pattern (e.g., `const findCacheDirectory = require('find-cache-directory')` with ES module)","error":"TypeError: findCacheDirectory is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/sindresorhus/find-cache-directory#readme","github":"https://github.com/sindresorhus/find-cache-directory","docs":null,"changelog":null,"pypi":null,"npm":"find-cache-directory","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops","storage"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}