fsModuleCachePath 5.0.0+
- Type:
string - Default:
'node_modules/.vitest-cache'(resolved from the workspace root) - CLI:
--fsModuleCachePath=<path>
Directory where the fsModuleCache is stored.
This can be set per project; projects that don't override it fall back to the root's cache directory. The lockfile metadata used to invalidate the cache is always shared across the whole workspace.
By default Vitest stores the cache inside node_modules at the workspace root. The root is based on your package manager's lockfile (for example, .package-lock.json, .yarn-state.yml, .pnpm/lock.yaml and so on). Keeping it inside node_modules means the cache is naturally invalidated whenever dependencies are reinstalled.
If the config and the CLI do not set this option, Vitest reads it from the VITEST_FS_MODULE_CACHE_PATH environment variable. A relative path is resolved from the root.
import { defineConfig } from 'vitest/config'
export default defineConfig({
test: {
fsModuleCache: true,
fsModuleCachePath: 'node_modules/.vitest-cache',
},
})