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.
Cache
✓ import Cache from 'cache-point'
✗ const Cache = require('cache-point')
Package is ESM-only since v3; CommonJS require() will fail with ERR_REQUIRE_ESM
Cache
✓ import { Cache } from 'cache-point'
✗ const { Cache } = require('cache-point')
Named export also available but default export is recommended per documentation
Cache
✓ const Cache = (await import('cache-point')).default
✗ const { default: Cache } = require('cache-point')
Dynamic import is the workaround for CJS projects; the named export is identical to default
Demonstrates basic cache operations: write, read with hit/miss handling, and clear.
import Cache from 'cache-point';
const cache = new Cache({ dir: 'tmp/cache' });
async function example() {
// Write to cache
await cache.write('myKey', { data: 'hello' });
// Read from cache (on hit)
const value = await cache.read('myKey');
console.log(value); // { data: 'hello' }
// Read with miss handling
try {
const missing = await cache.read('nonexistent');
} catch (err) {
if (err.code === 'ENOENT') {
console.log('Cache miss');
}
}
// Clear all entries
await cache.clear();
}
example();
Debug
Known issues
breakingv3.0.0 dropped CommonJS support; package is ESM-only. Use dynamic import in CJS projects or upgrade to ESM.fixUse import (static or dynamic) instead of require(). Ensure package.json has type: module or use .mjs extension.
affects: >=3.0.0
breakingv3.0.0 requires Node.js >= 12.17. Older Node versions will throw SyntaxError for ESM syntax.fixUpgrade Node.js to >= 12.17.0.
affects: >=3.0.0
gotchaRead method rejects with ENOENT on miss, not undefined. Must use try/catch or .catch() to handle misses.fixWrap cache.read() in try/catch and check err.code === 'ENOENT'. Or use cache.readSync() which returns undefined on miss.
affects: >=1.0.0
gotchaKeys can be any JSON-serializable value; non-serializable keys (e.g., functions) will cause errors.fixEnsure keys are strings, numbers, booleans, arrays, or plain objects. Avoid symbols, functions, or circular references.
affects: >=1.0.0
deprecatedNo deprecation warnings known. Package is actively maintained.
Errors
Common errors & fixes
ERR_REQUIRE_ESM: require() of ES Module /path/to/node_modules/cache-point/index.js from /path/to/app.js not supported.
Using require() with an ESM-only package (v3+).
fixSwitch to import statement or use dynamic import: const Cache = (await import('cache-point')).default; SyntaxError: Unexpected token 'export'
Running an ESM package in a Node.js version < 12.17 or without proper module configuration.
fixUpgrade Node.js to >= 12.17 and ensure package.json includes "type": "module" or use .mjs extension.
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/path/to/node_modules/@75lb/nature'
Missing peer dependency @75lb/nature, which is required if not using optional features that bypass it.
fixRun npm install @75lb/nature or install cache-point with --legacy-peer-deps if not needed.
TypeError: cache.read(...) is not a function
Using named import { Cache } incorrectly (e.g., importing a non-existent function) or using an older version without that method.
fixEnsure you are importing Cache from 'cache-point' correctly: import Cache from 'cache-point'; then use new Cache().read().
Audit
Dependencies
@75lb/natureoptionalProvides ESM utilities (e.g., mkdirp, rimraf) used internally