{"id":30162971,"url":"https://github.com/ali-master/prune-mod","last_synced_at":"2026-01-20T17:38:23.085Z","repository":{"id":309005620,"uuid":"1034800784","full_name":"ali-master/prune-mod","owner":"ali-master","description":"Fast and efficient tool to reduce node_modules size by up to 60%. Safely removes unnecessary files like docs, tests, and dev configs while keeping your app working perfectly. Ideal for serverless, Docker, and deployment optimization.","archived":false,"fork":false,"pushed_at":"2025-08-09T08:01:37.000Z","size":130,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-08-09T08:30:56.808Z","etag":null,"topics":["bun","devops","disk-saver","docker","node-modules-clean","nodejs"],"latest_commit_sha":null,"homepage":"https://prune-mod.usestrict.dev","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ali-master.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-09T02:38:15.000Z","updated_at":"2025-08-09T08:01:40.000Z","dependencies_parsed_at":"2025-08-09T08:31:00.242Z","dependency_job_id":"939546ce-3c7e-4b15-ab11-ff4f48b24d41","html_url":"https://github.com/ali-master/prune-mod","commit_stats":null,"previous_names":["ali-master/prune-mod"],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/ali-master/prune-mod","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ali-master%2Fprune-mod","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ali-master%2Fprune-mod/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ali-master%2Fprune-mod/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ali-master%2Fprune-mod/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ali-master","download_url":"https://codeload.github.com/ali-master/prune-mod/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ali-master%2Fprune-mod/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269930263,"owners_count":24498686,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-11T02:00:10.019Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bun","devops","disk-saver","docker","node-modules-clean","nodejs"],"created_at":"2025-08-11T17:48:57.514Z","updated_at":"2026-01-20T17:38:23.079Z","avatar_url":"https://github.com/ali-master.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n![prune-mod Logo](assets/logo.svg)\n\n# prune-mod\n\nA fast and efficient tool to reduce node_modules size by removing unnecessary files. Save up to 60% disk space by cleaning out docs, tests, and development files while keeping your code working perfectly.\n\n**Ultra-lightweight at just 18.6 KB** (6 KB gzipped) - smaller than most images, yet powerful enough to save hundreds of megabytes!\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n[![npm version](https://badge.fury.io/js/@usex%2Fprune-mod.svg)](https://badge.fury.io/js/@usex%2Fprune-mod)\n[![CI/CD Pipeline](https://github.com/ali-master/prune-mod/actions/workflows/ci.yml/badge.svg)](https://github.com/ali-master/prune-mod/actions/workflows/ci.yml)\n\n\u003ca href=\"https://www.producthunt.com/products/prune-mod?embed=true\u0026utm_source=badge-featured\u0026utm_medium=badge\u0026utm_source=badge-prune\u0026#0045;mod\" target=\"_blank\"\u003e\u003cimg src=\"https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=1012152\u0026theme=light\u0026t=1759345850493\" alt=\"Prune\u0026#0032;Mod - Fast\u0026#0032;and\u0026#0032;efficient\u0026#0032;tool\u0026#0032;to\u0026#0032;reduce\u0026#0032;node\u0026#0095;modules\u0026#0032;size | Product Hunt\" style=\"width: 250px; height: 54px;\" width=\"250\" height=\"54\" /\u003e\u003c/a\u003e\n\u003c/div\u003e\n\n\n## Why prune-mod?\n\nNode.js projects often have large node_modules folders filled with unnecessary files like documentation, tests, and build configs. These files take up valuable disk space and slow down deployments. prune-mod safely removes these files while keeping your application working perfectly.\n\n**Key Benefits:**\n- **Reduce size by 60%** - Dramatically shrink your node_modules\n- **Faster deployments** - Less data to transfer and extract\n- **Lower storage costs** - Save money on serverless and container deployments\n- **Safe by default** - Never breaks your application\n- **Lightning fast** - Process thousands of files in seconds\n- **Smart runtime detection** - Automatically uses the fastest available runtime (Bun or Node.js)\n- **Workspace/Monorepo support** - Automatically detects and prunes all packages in your monorepo\n\n## Quick Start\n\n```bash\n# Install globally\nnpm install -g @usex/prune-mod\n\n# Use in any project\nprune-mod\n\n# Or run without installing\nnpx @usex/prune-mod\n```\n\n## Installation\n\n### npm / yarn / pnpm\n\n```bash\n# npm\nnpm install -g @usex/prune-mod\n\n# yarn\nyarn global add @usex/prune-mod\n\n# pnpm\npnpm add -g @usex/prune-mod\n```\n\n### Bun (Recommended)\n\n```bash\nbun install -g @usex/prune-mod\n```\n\n### Run without installing\n\n```bash\n# npm\nnpx @usex/prune-mod\n\n# bun\nbunx @usex/prune-mod\n```\n\n## Usage\n\n### Basic usage\n\n```bash\n# Clean current project's node_modules\nprune-mod\n\n# Clean specific directory\nprune-mod ./my-project/node_modules\n\n# Preview what will be removed (safe to run)\nprune-mod --dry-run\n\n# See detailed output\nprune-mod --verbose\n```\n\n### Command options\n\n```\nUsage:\n  prune-mod [options] [directory]\n\nOptions:\n  -v, --verbose         Show detailed output\n  --exclude \u003cpattern\u003e   Don't remove files matching this pattern\n  --include \u003cpattern\u003e   Always remove files matching this pattern\n  -d, --dry-run         Preview changes without removing files\n  -w, --workspace       Enable workspace/monorepo mode\n  --workspace-root \u003cdir\u003e Specify workspace root (auto-detected if not provided)\n  --no-root             Skip pruning root node_modules in workspace mode\n  --experimental-default-files Enable experimental extended file list for more aggressive pruning\n  -h, --help            Show help\n\nExamples:\n  prune-mod                              # Clean ./node_modules\n  prune-mod ./dist/node_modules         # Clean specific directory\n  prune-mod --exclude \"*.config.js\"    # Keep config files\n  prune-mod --dry-run --verbose         # Preview with details\n  \nWorkspace Examples:\n  prune-mod --workspace                 # Auto-detect and prune all packages\n  prune-mod -w --no-root               # Prune only package node_modules\n  prune-mod -w --workspace-root /monorepo # Specify workspace root\n  \nExperimental Examples:\n  prune-mod --experimental-default-files    # Use extended file list\n  prune-mod -w --experimental-default-files # Combine with workspace mode\n```\n\n### Real-world examples\n\n**Before deployment:**\n```bash\n# Install production dependencies\nnpm ci --production\n\n# Remove unnecessary files\nprune-mod --verbose\n\n# Your bundle is now 60% smaller!\n```\n\n**Docker builds:**\n```dockerfile\nFROM node:18-alpine AS builder\n\nWORKDIR /app\nCOPY package*.json ./\nRUN npm ci --production\n\n# Clean up node_modules\nRUN npx @usex/prune-mod\n\nFROM node:18-alpine\nWORKDIR /app\nCOPY --from=builder /app/node_modules ./node_modules\nCOPY . .\n\nCMD [\"node\", \"index.js\"]\n```\n\n**Custom patterns:**\n```bash\n# Keep specific files you need\nprune-mod --exclude \"*.d.ts\" --exclude \"LICENSE\"\n\n# Remove additional file types\nprune-mod --include \"*.log\" --include \"*.tmp\"\n```\n\n## What gets removed?\n\nprune-mod safely removes these types of files:\n\n### Documentation files\n- README files (README.md, README.txt, etc.)\n- CHANGELOG and HISTORY files  \n- LICENSE and COPYRIGHT files\n- Documentation directories (docs/, doc/)\n\n### Development files\n- Test files and directories (test/, tests/, __tests__/)\n- Example files and directories\n- Source maps (*.map files)\n- TypeScript config (tsconfig.json, tslint.json)\n\n### Build and config files\n- Linting configs (.eslintrc, .prettierrc, etc.)\n- CI/CD configs (.github/, .circleci/, etc.)\n- Editor configs (.vscode/, .idea/, .editorconfig)\n- Build tool configs (webpack.config.js, etc.)\n\n### Temporary files\n- Coverage reports\n- Log files\n- Temporary directories\n- Cache files\n\n**Important:** prune-mod never removes:\n- Main entry files (package.json main/module/exports)\n- Runtime dependencies\n- Binary executables\n- Critical system files\n\n### Experimental Extended File List\n\nFor even more aggressive space savings, prune-mod offers an experimental mode that removes additional safe files:\n\n```bash\n# Enable experimental extended file list\nprune-mod --experimental-default-files\n\n# Use with other options\nprune-mod --experimental-default-files --workspace --verbose\n```\n\n**Experimental mode adds 140+ additional file patterns** including:\n- Extended documentation files (CHANGELOG.md, CODE_OF_CONDUCT.md, SECURITY.md)\n- Advanced configuration files (webpack.config.*, rollup.config.*, vite.config.*)\n- Git and version control files (.gitignore, .gitkeep, .dockerignore)\n- CI/CD configurations (azure-pipelines.yml, .drone.yml, buildkite.yml)\n- Code quality tools (.codeclimate.yml, codecov.yml, sonar-project.properties)\n- Build outputs and caches (dist/, build/, .cache/, .next/, .nuxt/)\n- Source maps and minified files (*.map, *.min.js, *.min.css)\n- Environment and runtime files (.env.example, .nvmrc, .python-version)\n\n**Safety note:** Experimental mode is thoroughly tested but more aggressive. Always test with `--dry-run` first to ensure it meets your needs.\n\n## Programming API\n\nUse prune-mod in your Node.js applications:\n\n```javascript\nimport { Pruner } from '@usex/prune-mod';\n\nconst pruner = new Pruner({\n  dir: './node_modules',\n  verbose: true,\n  dryRun: false,\n  exceptions: ['*.config.*'], // Files to keep\n  globs: ['**/*.tmp'],        // Files to remove\n  experimental: {\n    defaultFiles: true        // Enable extended file list\n  }\n});\n\nconst stats = await pruner.prune();\n\nconsole.log(`Removed ${stats.filesRemoved} files`);\nconsole.log(`Saved ${stats.sizeRemoved} bytes`);\nconsole.log(`Processed ${stats.filesTotal} total files`);\n```\n\n### Workspace API\n\n```javascript\nimport { Pruner, WorkspaceDetector } from '@usex/prune-mod';\n\n// Auto-detect and prune workspace\nconst pruner = new Pruner({\n  dir: '.',\n  workspace: true,\n  includeRoot: true,\n  verbose: true\n});\n\nconst stats = await pruner.prune();\n\n// Or manually detect workspace info\nconst detector = new WorkspaceDetector();\nconst info = await detector.detect('.');\nconsole.log(`Workspace type: ${info.type}`);\nconsole.log(`Packages found: ${info.packages.length}`);\n```\n\n### Configuration options\n\n```typescript\ninterface PrunerOptions {\n  dir?: string;           // Target directory (default: \"node_modules\")\n  verbose?: boolean;      // Show detailed output (default: false)\n  dryRun?: boolean;       // Preview mode (default: false)\n  exceptions?: string[];  // Patterns for files to keep\n  globs?: string[];       // Additional patterns to remove\n  files?: string[];       // Custom file names to remove\n  directories?: string[]; // Custom directory names to remove\n  extensions?: string[];  // Custom file extensions to remove\n  \n  // Workspace options\n  workspace?: boolean;    // Enable workspace mode (default: false)\n  workspaceRoot?: string; // Custom workspace root (auto-detected if not set)\n  includeRoot?: boolean;  // Include root node_modules (default: true)\n  \n  // Experimental options\n  experimental?: {\n    defaultFiles?: boolean; // Enable extended file list (default: false)\n  };\n}\n```\n\n## Performance\n\nBenchmark results on a typical Next.js project:\n\n| Metric | Before | After | Improvement |\n|--------|--------|-------|-------------|\n| **Total Size** | 487 MB | 193 MB | **60% smaller** |\n| **File Count** | 21,543 | 12,105 | **44% fewer files** |\n| **Directories** | 2,847 | 1,923 | **32% fewer dirs** |\n| **Processing Time** | - | 2.3s | **Very fast** |\n\nResults vary by project, but most see 40-70% size reduction.\n\n## Smart Runtime Detection\n\nprune-mod features intelligent runtime detection that automatically selects the optimal JavaScript runtime for maximum performance:\n\n### How it works\n\nWhen you run `prune-mod`, the tool automatically detects your environment and chooses the best runtime:\n\n```bash\n# prune-mod automatically detects and uses:\n# → Bun (if available) - Up to 3x faster processing\n# → Node.js (fallback) - Reliable and widely available\n```\n\n### Performance comparison\n\n| Runtime | Processing Speed | Memory Usage | Best For |\n|---------|------------------|--------------|----------|\n| **Bun** | **3x faster** | 40% less memory | Local dev, CI/CD |\n| **Node.js** | Standard speed | Standard memory | Production, compatibility |\n\n### Zero configuration required\n\nThe runtime detection is completely automatic:\n\n- **Development with Bun installed**: Uses Bun for lightning-fast processing\n- **CI/CD pipelines**: Automatically adapts to available runtime\n- **Docker containers**: Works with any Node.js or Bun base image\n- **Legacy systems**: Falls back gracefully to Node.js\n\n### Benefits for different environments\n\n**Local Development:**\n- Bun users get 3x faster pruning\n- Instant feedback with `--dry-run`\n- Reduced waiting time in development workflow\n\n**CI/CD Pipelines:**\n- Automatically uses fastest available runtime\n- Reduces build times significantly\n- Works in any containerized environment\n\n**Production Deployments:**\n- Guaranteed compatibility with Node.js\n- Optimal performance when Bun is available\n- No runtime-specific configuration needed\n\n## Workspace/Monorepo Support\n\nprune-mod intelligently detects and handles all major monorepo tools, making it perfect for large-scale projects with multiple packages.\n\n### Supported Workspace Types\n\n| Tool | Detection | Features |\n|------|-----------|----------|\n| **npm workspaces** | `package.json` with `workspaces` field | Hoisted dependencies, per-package pruning |\n| **Yarn workspaces** | `yarn.lock` + workspaces config | Classic and Berry support |\n| **pnpm workspaces** | `pnpm-workspace.yaml` | Efficient handling of hard links |\n| **Lerna** | `lerna.json` | Multi-package repository support |\n| **Nx** | `nx.json` or `workspace.json` | Monorepo with affected detection |\n| **Rush** | `rush.json` | Enterprise-scale monorepo support |\n| **Turbo** | `turbo.json` | High-performance build system with workspaces |\n| **Bun workspaces** | Bun with workspaces config | Native Bun workspace handling |\n\n### How Workspace Mode Works\n\nWhen you run `prune-mod --workspace`, it:\n\n1. **Auto-detects** your monorepo type and structure\n2. **Identifies** all workspace packages automatically\n3. **Prunes** both root and package-level node_modules\n4. **Preserves** workspace integrity and symlinks\n5. **Reports** consolidated statistics for all packages\n\n### Workspace Examples\n\n**Basic workspace pruning:**\n```bash\n# Auto-detect and prune entire monorepo\nprune-mod --workspace\n\n# Preview what will be removed\nprune-mod -w --dry-run --verbose\n```\n\n**Advanced workspace control:**\n```bash\n# Skip root node_modules (only prune packages)\nprune-mod -w --no-root\n\n# Specify custom workspace root\nprune-mod -w --workspace-root /path/to/monorepo\n\n# Combine with other options\nprune-mod -w --exclude \"*.config.js\" --verbose\n```\n\n**Real-world monorepo example:**\n```bash\n# In a large Nx monorepo\ncd my-nx-workspace\nprune-mod --workspace\n\n# Output:\n# Detected nx workspace at /my-nx-workspace\n# Found 25 workspace packages\n# Pruning root node_modules at /my-nx-workspace/node_modules\n# Pruning package node_modules at /my-nx-workspace/apps/web/node_modules\n# ...\n# files removed: 15,234\n# size removed: 285 MB\n```\n\n### Workspace Performance\n\nBenchmark on a typical monorepo with 20 packages:\n\n| Metric | Before | After | Improvement |\n|--------|--------|-------|-------------|\n| **Total Size** | 1.8 GB | 680 MB | **62% smaller** |\n| **File Count** | 95,420 | 41,183 | **57% fewer files** |\n| **Docker Image** | 2.1 GB | 890 MB | **58% smaller** |\n| **CI Cache Time** | 4m 20s | 1m 45s | **60% faster** |\n\n### Best Practices for Workspaces\n\n1. **CI/CD Integration:**\n   ```yaml\n   # GitHub Actions example\n   - name: Install and prune\n     run: |\n       npm ci\n       npx @usex/prune-mod --workspace\n   ```\n\n2. **Docker Optimization:**\n   ```dockerfile\n   FROM node:18 AS builder\n   WORKDIR /app\n   COPY . .\n   RUN npm ci \u0026\u0026 npx @usex/prune-mod -w\n   \n   FROM node:18-alpine\n   COPY --from=builder /app .\n   ```\n\n3. **Selective Pruning:**\n   ```bash\n   # Only prune specific packages (manual mode)\n   prune-mod ./packages/app-a/node_modules\n   prune-mod ./packages/app-b/node_modules\n   ```\n\n## Use Cases\n\n### Serverless functions\nReduce cold start times and stay under size limits:\n```bash\nnpm ci --production\nprune-mod\nzip -r function.zip .\n```\n\n### Docker containers\nSmaller images mean faster pulls and deployments:\n```dockerfile\nRUN npm ci --production \u0026\u0026 npx @usex/prune-mod\n```\n\n### CI/CD pipelines\nSpeed up builds and deployments:\n```yaml\n- name: Install dependencies\n  run: npm ci --production\n  \n- name: Clean node_modules\n  run: npx @usex/prune-mod --verbose\n```\n\n### Local development\nFree up disk space on your machine:\n```bash\n# Clean all projects in a directory\nfind . -name \"node_modules\" -type d -exec prune-mod {} \\;\n```\n\n## Safety\n\nprune-mod is designed to be safe:\n\n- **Respects package.json** - Never removes main entry files\n- **Dry run mode** - Preview changes before applying them  \n- **Extensive testing** - Tested on thousands of real packages\n- **Rollback friendly** - Just run `npm install` to restore files\n- **Non-destructive** - Only removes files that can be regenerated\n\n## Requirements\n\n- Node.js 18+ or Bun 1.0+\n- Works on Windows, macOS, and Linux\n\n## Contributing\n\nWe welcome contributions! Here's how to help:\n\n1. **Report bugs** - Open an issue with details\n2. **Suggest features** - Tell us what you need\n3. **Submit code** - Fork, branch, code, test, PR\n4. **Improve docs** - Help others understand the tool\n5. **Share feedback** - Let us know how it works for you\n\n### Development setup\n\n```bash\n# Clone the repository\ngit clone https://github.com/ali-master/prune-mod.git\ncd prune-mod\n\n# Install dependencies\nbun install\n\n# Run tests\nbun test\n\n# Start development\nbun run dev\n\n# Build for production\nbun run build\n```\n\n## FAQ\n\n**Q: Is it safe to use in production?**  \nA: Yes! prune-mod only removes files that aren't needed at runtime.\n\n**Q: What if I need a file that gets removed?**  \nA: Use `--exclude` to keep specific files, or just run `npm install` to restore everything.\n\n**Q: How much space will I save?**  \nA: Typically 40-70% depending on your dependencies. Use `--dry-run` to preview.\n\n**Q: Does it work with Yarn/pnpm?**  \nA: Yes! prune-mod works with any package manager.\n\n**Q: Can I use it in automated scripts?**  \nA: Absolutely! It's designed for CI/CD pipelines and automated deployments.\n\n## License\n\nMIT License - see [LICENSE](LICENSE) file for details.\n\n## Related Tools\n\n- [node-prune](https://github.com/tj/node-prune) - Go-based alternative\n- [npm-prune](https://docs.npmjs.com/cli/v7/commands/npm-prune) - Built-in npm command for dev dependencies\n- [clean-modules](https://github.com/mikechabot/clean-modules) - Similar cleaning tool\n\n---\n\n\u003cdiv align=\"center\"\u003e\n\n**Built with ❤️ by [Ali Torki](https://github.com/ali-master) for the developer community**\n\n**If prune-mod saved you time and disk space, please give it a ⭐ on GitHub!**\n\n\u003c/div\u003e\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fali-master%2Fprune-mod","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fali-master%2Fprune-mod","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fali-master%2Fprune-mod/lists"}