Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
default
✓ const fsStore = require('cache-manager-fs');
✗ import fsStore from 'cache-manager-fs';
This package does not provide ESM exports; use CommonJS require.
default
✓ const { caching } = require('cache-manager'); const fsStore = require('cache-manager-fs'); const cache = caching({ store: fsStore });
✗ const cache = require('cache-manager-fs');
cache-manager-fs is a store factory, not a cache instance. It must be used with cache-manager's caching() function.
default
✓ import { caching } from 'cache-manager'; const fsStore = require('cache-manager-fs'); const cache = await caching({ store: fsStore });
✗ import fsStore from 'cache-manager-fs';
Even when using ESM for cache-manager, cache-manager-fs must be required or imported via default with a workaround.
Demonstrates basic setup with cache-manager and cache-manager-fs, including set, get, and ttl operations.
const cacheManager = require('cache-manager');
const fsStore = require('cache-manager-fs');
const diskCache = cacheManager.caching({
store: fsStore,
options: {
path: 'diskcache',
ttl: 60 * 60,
maxsize: 1000 * 1000 * 1000,
zip: true,
preventfill: true
}
});
(async () => {
await diskCache.set('myKey', 'myValue');
const val = await diskCache.get('myKey');
console.log(val); // 'myValue'
const ttl = await diskCache.ttl('myKey');
console.log(ttl); // 3600
})();
Errors
Common errors & fixes
Error: Cannot find module 'cache-manager'
Missing peer dependency cache-manager.
fixnpm install cache-manager
TypeError: cacheManager.caching is not a function
Incorrect import of cache-manager or using wrong API.
fixEnsure you require('cache-manager') correctly and use caching() method. SyntaxError: Unexpected identifier in import statement
Using ESM import with a CommonJS-only package.
fixUse require() instead of import.
Audit
Dependencies
cache-managerrequiredRequired peer dependency; this is a store for cache-manager.