deno clean
Remove the Deno cache directory to free up disk space or force re-downloading of dependencies.Basic usage
- Downloaded remote modules
- Compiled TypeScript files
- npm packages
- Generated source maps
Syntax
Options
Clean the cache except for dependencies used by the specified entry points. This allows you to remove unused cached files while keeping dependencies for specific projects.
Show what would be removed without actually deleting files.
Examples
Clean entire cache
Dry run
Clean except specific dependencies
main.ts and its dependencies.
What gets removed
Thedeno clean command removes:
Remote module cache
Remote module cache
Downloaded files from
https:// and http:// imports.Location: $DENO_DIR/deps/Generated JavaScript
Generated JavaScript
Transpiled TypeScript files and source maps.Location:
$DENO_DIR/gen/npm packages
npm packages
Downloaded npm packages and their metadata.Location:
$DENO_DIR/npm/node_modules (local)
node_modules (local)
When using
--except, unused packages from node_modules/.deno/ are also removed.Cache location
The Deno cache directory location varies by operating system:| OS | Default Location |
|---|---|
| Linux/Unix | $HOME/.cache/deno |
| macOS | $HOME/Library/Caches/deno |
| Windows | %LOCALAPPDATA%\deno |
DENO_DIR environment variable:
Use cases
Free disk space
Remove all cached files to reclaim storage
Fix cache corruption
Clear corrupted cache to force fresh downloads
Test fresh installs
Verify dependency resolution works correctly
Remove old dependencies
Clean up unused dependencies from old projects
Selective cleaning with —except
The--except flag is useful for maintaining a clean cache while preserving dependencies for active projects:
- Analyzes the module graph for specified entry points
- Identifies all required dependencies
- Removes cached files not used by those dependencies
- Also cleans up unused npm packages and node_modules symlinks
After cleaning
After runningdeno clean, the next time you run a Deno command:
- Remote modules will be re-downloaded
- TypeScript files will be re-compiled
- npm packages will be re-installed
Best practices
See also
deno cache- Pre-download and cache dependenciesdeno info- View cache location and dependency tree