Registry / devops / npm-cache-rm

npm-cache-rm

JSON →
library0.0.3jsnpmunverified

A minimal CLI tool to remove specific entries from the npm cache by regex pattern matching on cache keys. Version 0.0.3, no active release cadence. Simple single-purpose tool with zero dependencies beyond Node.js's built-in modules. Differentiator: allows targeted cache cleanup vs clearing the entire npm cache.

npm install npm-cache-rm
INSTALL
IMPORT
SIG · NPM-CACHE-RM
N
npm-cache-rm
devopsjavascriptv0.0.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

List all cache entries matching 'electron' (dry-run), then remove entries matching the regex pattern for Electron 10.0.0.

npx npm-cache-rm --dry-run electron npx npm-cache-rm "electron.*?10\\.0\\.0"
Debug
Known issues
gotchaThe regex pattern is matched against the full cache key, not just package names. Ensure proper escaping of dots and special characters.
fix
Use proper regex escaping, e.g., for exact version use 'electron.*?10\\.0\\.0'.
affects: >=0.0.0
gotchaDry-run prints 'rm ...' lines but does not actually remove anything. Users often assume it only lists matching entries without 'rm' prefix.
fix
Run with --dry-run to preview, then remove --dry-run to execute.
affects: >=0.0.0
gotchaThe tool only works with npm cache entries stored via make-fetch-happen and pacote. Custom registries or different cache formats may not be affected.
fix
Use npm cache ls to verify cache keys before attempting to remove.
affects: >=0.0.0
breakingNo error if the regex matches nothing; exits silently. Users may think cleanup happened when no entries matched.
fix
Manually verify cache contents with 'npm cache ls' before and after.
affects: >=0.0.0
gotchaRequires Node.js and npm installed. Not a standalone executable.
fix
Ensure Node.js is in PATH.
affects: >=0.0.0
Errors
Common errors & fixes
rm: missing operand
The tool internally uses 'rm' command but does not validate regex argument.
fix
Ensure you provide a regex pattern as argument, e.g., 'npm-cache-rm electron'
SyntaxError: Invalid regular expression
Invalid regex pattern passed as argument.
fix
Use valid regex syntax; escape special characters. Example: 'npm-cache-rm "electron.*?10\\.0\\.0"'
The tool appears to do nothing on Windows
Uses Unix shell commands (rm) under the hood.
fix
Run on Linux/macOS or use WSL on Windows.
Upgrade
Version history
0.0.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
npm-cache-rm — npm install npm-cache-rm · libregistry