{"id":"24b7896c70baabf3","repo":"vitest-dev/vitest","slug":"cache-dir-is-deprecated","errorCode":null,"errorMessage":"--cache.dir is deprecated","messagePattern":"--cache\\.dir is deprecated","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/vitest/src/node/cli/cli-config.ts","lineNumber":772,"sourceCode":"      'Threshold in milliseconds for a test or suite to be considered slow (default: `300`)',\n    argument: '<threshold>',\n  },\n  teardownTimeout: {\n    description:\n      'Default timeout of a teardown function in milliseconds (default: `10000`)',\n    argument: '<timeout>',\n  },\n  cache: {\n    description: 'Enable cache',\n    argument: '', // allow only boolean\n    subcommands: {\n      dir: null,\n    },\n    default: true,\n    // cache can only be \"false\" or an object\n    transform(cache) {\n      if (typeof cache !== 'boolean' && cache) {\n        throw new Error('--cache.dir is deprecated')\n      }\n      if (cache) {\n        return {}\n      }\n      return cache\n    },\n  },\n  maxConcurrency: {\n    description: 'Maximum number of concurrent tests and suites during test file execution (default: `5`)',\n    argument: '<number>',\n  },\n  fsModuleCache: {\n    description: 'Cache transformed modules on the file system and reuse them between reruns (default: `false`)',\n  },\n  fsModuleCachePath: {\n    description: 'Directory where the `fsModuleCache` is stored (default: `node_modules/.vitest-cache`)',\n    argument: '<path>',\n  },","sourceCodeStart":754,"sourceCodeEnd":790,"githubUrl":"https://github.com/vitest-dev/vitest/blob/d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09/packages/vitest/src/node/cli/cli-config.ts#L754-L790","documentation":"Thrown by the `--cache` option transform when cache is configured as a non-boolean truthy value. In Vitest 4 the `--cache.dir` sub-option was removed; cache is now a simple boolean (default true) and the cache directory is managed internally. Passing an object/string (the old `cache: { dir: ... }` shape) triggers this deprecation-turned-error.","triggerScenarios":"Using `--cache.dir=<path>` on the CLI, or setting `cache: { dir: '...' }` / `cache: 'somepath'` in config; the transform receives a non-boolean truthy value and throws because the old shape is no longer supported.","commonSituations":"Upgrading from Vitest 3 (or earlier) where `cache.dir` was valid; copying old config examples; CI configs that pinned a cache directory.","solutions":["Remove `cache.dir` / `--cache.dir`. Use `--cache` (true, default) or `--no-cache` to toggle caching.","If you need to control where the cache lives, use the dedicated `fsModuleCachePath` option for module caching instead.","Update any shared config presets or Dockerfile/CI templates that reference `cache.dir`."],"exampleFix":"// before\nexport default { cache: { dir: './.vitest-cache' } }\n// after\nexport default { cache: true, fsModuleCachePath: './.vitest-cache' }","handlingStrategy":"validation","validationCode":"if (cache !== true && cache !== false) {\n  throw new Error('cache must be a boolean in Vitest 4; cache.dir was removed')\n}","typeGuard":"function isCacheOption(v: unknown): v is boolean {\n  return typeof v === 'boolean'\n}","tryCatchPattern":null,"preventionTips":["After upgrading to Vitest 4, search the repo for `cache.dir` and `cache: {` and remove them.","Use a boolean for cache; use fsModuleCachePath for module-cache location.","Update shared CI/Docker templates that pin a cache dir."],"tags":[],"analyzedSha":"d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09","analyzedAt":"2026-08-03T20:23:56.861Z","schemaVersion":2}