{"id":46742,"library":"v8-compile-cache","title":"v8-compile-cache","description":"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.","status":"active","version":"2.4.0","language":"javascript","source_language":"en","source_url":"https://github.com/zertosh/v8-compile-cache","tags":["javascript"],"install":[{"cmd":"npm install v8-compile-cache","lang":"bash","label":"npm"},{"cmd":"yarn add v8-compile-cache","lang":"bash","label":"yarn"},{"cmd":"pnpm add v8-compile-cache","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"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.","wrong":"import v8CompileCache from 'v8-compile-cache'","symbol":"default import","correct":"require('v8-compile-cache')"},{"note":"The module does not export any symbols; it only attaches the require hook as a side effect.","wrong":"const { cache } = require('v8-compile-cache')","symbol":"no named exports","correct":"require('v8-compile-cache')"},{"note":"Dynamic import works but the result is undefined. Use side-effect import only.","wrong":"import('v8-compile-cache').then(m => m.default)","symbol":"dynamic import","correct":"await import('v8-compile-cache')"}],"quickstart":{"code":"// In your application's entry point (e.g., index.js):\nrequire('v8-compile-cache');\n\n// Then require other modules as usual:\nconst express = require('express');\nconst app = express();\napp.get('/', (req, res) => { res.send('Hello World!'); });\napp.listen(3000, () => console.log('Server running on port 3000'));","lang":"javascript","description":"Shows minimal setup: add v8-compile-cache as the first require to enable cached compilation for all subsequent modules."},"warnings":[{"fix":"Move require('v8-compile-cache') to the very top of your entry file.","message":"Requiring v8-compile-cache after other modules is a no-op – it must be required before any modules you want to cache.","severity":"gotcha","affected_versions":"*"},{"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.","message":"Cache directory may grow unbounded over time; it is not automatically cleaned.","severity":"gotcha","affected_versions":"*"},{"fix":"Consider alternatives like --experimental-vm-modules or native ESM caching. The module is unmaintained for newer Node.js versions.","message":"In Node >=20, the V8 code cache format changed, causing this module to have no effect. It is untested and may cause errors.","severity":"breaking","affected_versions":">=2.4.0"},{"fix":"Look for actively maintained alternatives or use Node's built-in ESM loader hooks.","message":"The module is no longer maintained and may be removed from registry. No new features or Node.js version support.","severity":"deprecated","affected_versions":">=2.4.0"}],"env_vars":null,"search_vec":"'-50':72 '15':71 '2.4.0':26 '2021':36 '5.7.0':41 'altern':84 'applic':24 'attach':5 'automat':59 'babel':80 'babel-cor':79 'babel/register':86 'base':62 'cach':4,14,60 'code':13 'compil':3 'complex':93 'config':50 'core':81 'differenti':47 'disk':16 'e.g':70 'entri':57 'faster':73 'file':58 'heavi':76 'hook':8 'improv':69 'invalid':61 'javascript':99 'key':46 'last':32 'latest':29 'like':78,85 'load':21,74 'modul':20,77 'node':40,89 'node-persist':88 'node.js':23 'noop':42 'notabl':67 'octob':35 'older':44 'perform':68 'persist':10,90 'releas':31 'requir':7,53 'setup':51 'signific':17 'specif':98 'speed':18 'stabl':30 'updat':33 'v8':2,11,64,97 'v8-compile-cache':1 'v8-specific':96 'version':25,45,65 'work':38 'yarn':83 'zero':49 'zero-config':48","created_at":"2026-06-07T13:01:24.780714+00:00","updated_at":"2026-06-07T13:01:24.780714+00:00","problems":[{"fix":"Clear the cache directory (default in tmp) and restart the application.","cause":"The cache file may be corrupted or created by a different Node version.","error":"Error: Module \"v8-compile-cache\" does not provide a valid cache file."},{"fix":"Use require('v8-compile-cache') instead of import.","cause":"Using ES module import syntax in a CommonJS file.","error":"SyntaxError: Unexpected identifier"},{"fix":"Run npm install v8-compile-cache and ensure it is listed in dependencies.","cause":"The package is not installed or not in node_modules.","error":"Cannot find module 'v8-compile-cache'"},{"fix":"Set DISABLE_V8_COMPILE_CACHE=1 in the same process before any require of v8-compile-cache.","cause":"Environment variable must be set before requiring the module.","error":"DISABLE_V8_COMPILE_CACHE=1 does not disable cache."}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/zertosh/v8-compile-cache#readme","github":"https://github.com/zertosh/v8-compile-cache","docs":null,"changelog":null,"pypi":null,"npm":"v8-compile-cache","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}