Registry / devops / v8-compile-cache

v8-compile-cache

JSON →
library2.4.0jsnpmunverified

Attaches a require hook to persist V8's code cache to disk, significantly speeding up module loading for Node.js applications. Version 2.4.0 is the latest stable release, last updated in October 2021. It works with Node >=5.7.0 (noop on older versions). Key differentiators: zero-config setup (just require it in your entry file), automatic cache invalidation based on V8 version, and notable performance improvements (e.g., 15-50% faster loading for heavy modules like babel-core and yarn). Alternatives like @babel/register or node-persist are more complex or not V8-specific.

npm install v8-compile-cache
INSTALL
IMPORT
SIG · V8-COMPILE-CACHE
V
v8-compile-cache
devopsjavascriptv2.4.0
harness data pending
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 import
require('v8-compile-cache')
import v8CompileCache from 'v8-compile-cache'
This module is intended to be used as a side-effect require, not imported as an ES module. It must be required before any other modules to take effect.
no named exports
require('v8-compile-cache')
const { cache } = require('v8-compile-cache')
The module does not export any symbols; it only attaches the require hook as a side effect.
dynamic import
await import('v8-compile-cache')
import('v8-compile-cache').then(m => m.default)
Dynamic import works but the result is undefined. Use side-effect import only.

Shows minimal setup: add v8-compile-cache as the first require to enable cached compilation for all subsequent modules.

// In your application's entry point (e.g., index.js): require('v8-compile-cache'); // Then require other modules as usual: const express = require('express'); const app = express(); app.get('/', (req, res) => { res.send('Hello World!'); }); app.listen(3000, () => console.log('Server running on port 3000'));
Debug
Known issues
gotchaRequiring v8-compile-cache after other modules is a no-op – it must be required before any modules you want to cache.
fix
Move require('v8-compile-cache') to the very top of your entry file.
affects: *
gotchaCache directory may grow unbounded over time; it is not automatically cleaned.
fix
Periodically delete the cache directory (default: os.tmpdir() + '/v8-compile-cache-<V8_VERSION>') or set V8_COMPILE_CACHE_CACHE_DIR to a managed location.
affects: *
breakingIn Node >=20, the V8 code cache format changed, causing this module to have no effect. It is untested and may cause errors.
fix
Consider alternatives like --experimental-vm-modules or native ESM caching. The module is unmaintained for newer Node.js versions.
affects: >=2.4.0
deprecatedThe module is no longer maintained and may be removed from registry. No new features or Node.js version support.
fix
Look for actively maintained alternatives or use Node's built-in ESM loader hooks.
affects: >=2.4.0
Errors
Common errors & fixes
Error: Module "v8-compile-cache" does not provide a valid cache file.
The cache file may be corrupted or created by a different Node version.
fix
Clear the cache directory (default in tmp) and restart the application.
SyntaxError: Unexpected identifier
Using ES module import syntax in a CommonJS file.
fix
Use require('v8-compile-cache') instead of import.
Cannot find module 'v8-compile-cache'
The package is not installed or not in node_modules.
fix
Run npm install v8-compile-cache and ensure it is listed in dependencies.
DISABLE_V8_COMPILE_CACHE=1 does not disable cache.
Environment variable must be set before requiring the module.
fix
Set DISABLE_V8_COMPILE_CACHE=1 in the same process before any require of v8-compile-cache.
Upgrade
Version history
2.4.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
v8-compile-cache — npm install v8-compile-cache · libregistry