Registry / devops / gulp-cache

gulp-cache

JSON →
library1.1.3jsnpmunverified

A temp file based caching proxy task for Gulp. Currently at version 1.1.3 (stable), with a maintenance status as the package is not actively developed. It caches the output of any Gulp plugin based on file contents or custom keys, reducing repeated processing. Unlike other caching approaches, it stores full plugin output in a swap file cache, and supports custom success/value extractors for result inspection. Requires Node >=8 and Gulp 4+.

npm install gulp-cache
INSTALL
IMPORT
SIG · GULP-CACHE
G
gulp-cache
devopsjavascriptv1.1.3
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 cache from 'gulp-cache'
const cache = require('gulp-cache').default
The default export is the cache function. Named export 'Cache' also available.
Cache
import { Cache } from 'gulp-cache'
import Cache from 'gulp-cache'
Cache is a named export for the cache store class. In TypeScript, you may need to import this for type annotations.
cache (CommonJS)
const cache = require('gulp-cache')
const { cache } = require('gulp-cache')
In CommonJS, require returns the default export directly, not an object with a 'cache' property.

Demonstrates basic usage of gulp-cache to cache the output of gulp-jshint, with custom success and value functions.

import gulp from 'gulp'; import jshint from 'gulp-jshint'; import cache from 'gulp-cache'; gulp.task('lint', () => gulp.src('src/**/*.js') .pipe(cache( jshint('.jshintrc'), { name: 'jshint-cache', success: (file) => file.jshint.success, value: (file) => ({ jshint: file.jshint }) } )) .pipe(jshint.reporter('default')) );
Debug
Known issues
breakingVersion 1.0.0 dropped support for Node <8 and Gulp <4. The old callback-based API was removed.
fix
Upgrade to Node >=8 and Gulp >=4. Use .pipe(cache(plugin, options)) syntax.
affects: >=1.0.0
deprecatedThe 'fileCache' option is deprecated; pass a custom Cache instance directly via options.cache or use the default.
fix
Replace fileCache with the 'cache' option.
affects: >=1.0.0
gotchaThe 'key' option does NOT auto-hash; you must provide a string or Promise<string>. The returned value is used as is for cache lookup.
fix
If you need hashing, hash the key yourself before returning.
affects: >=0.2.0
gotchaDo not assume the cache directory is cleaned automatically. The cache persists between runs unless cleared via cache.clear() or manually removed.
fix
Use cache.clear() in a clean task or schedule periodic cleanup.
affects: >=0.1.0
breakingIn version 0.4.0 the 'success' and 'value' options changed from being functions that take a callback to sync/async functions returning a value.
fix
Update success/file to return boolean, and value to return the object directly.
affects: >=0.4.0 <1.0.0
Errors
Common errors & fixes
Error: listen EACCES: permission denied /tmp/gulp-cache/...
Cache directory creation fails due to insufficient permissions (e.g., on CI or inside Docker).
fix
Set a custom cache directory with write permissions via options.cacheDir or environment variable.
TypeError: Cannot read property 'contents' of undefined
The 'key' option function receives a file object that might be null/undefined, or the stream is empty.
fix
Check that gulp.src() actually yields files. Ensure your key function handles falsy file gracefully.
Error: Cannot find module 'gulp-cache'
The package is not installed or not in node_modules.
fix
Run 'npm install --save-dev gulp-cache' or 'yarn add --dev gulp-cache'.
TypeError: cache is not a function
Import error: CommonJS require returns an object, not a function directly.
fix
Use 'const cache = require('gulp-cache');' (without destructuring). Or use ESM import syntax.
Upgrade
Version history
1.1.3latest on npm
Audit
Dependencies
gulprequiredPeer dependency: gulp-cache is a Gulp plugin and requires Gulp as the task runner.
cache-swaprequiredUnderlying cache storage implementation.
Agent activity
12 hits · last 30 days
node
12
Resources
gulp-cache — npm install gulp-cache · libregistry