reqscan
v1.2.0
Published
Dependency Manager for Node.js — scan, install, clean, and audit your project dependencies
Downloads
463
Maintainers
Readme
reqscan — Dependency Manager for Node.js
reqscan is a powerful CLI tool that scans your Node.js project, detects missing dependencies, and helps you manage them with simple commands. Zero external dependencies.
✨ Features
- 🔍 Check — Find imported packages missing from
package.json - 📦 Install — Install all missing packages at once
- 🧹 Clean — Remove unused/undeclared packages
- 🔧 Fix — Install missing + clean unused in one shot
- 🎯 Audit — Full dependency health report with score
- 📋 List — Show every dependency with its status
- 🚫 Smart filtering — Ignores built-ins,
node_modules, relative imports - 📁 Multi-language — Supports
.js,.ts,.jsx,.tsx,.mjs,.cjs - 🎨 Beautiful output — Color-coded terminal UI
- ⚡ Zero dependencies — Lightweight and fast
- 🔧 Programmatic API — Use it in your own tools
📦 Installation
Global Installation (Recommended)
npm install -g reqscanRun without installing (npx)
npx reqscan check
npx reqscan installLocal Installation (for CI/CD)
npm install --save-dev reqscanThen add to your package.json scripts:
{
"scripts": {
"deps:check": "reqscan check",
"deps:fix": "reqscan fix"
}
}🚀 Usage
# Scan current directory
reqscan check
# Scan specific project
reqscan check /path/to/project
# Install all missing dependencies
reqscan install
# Remove unused dependencies
reqscan clean
# Fix everything (install missing + remove unused)
reqscan fix
# Show full project health report
reqscan audit
# Show all packages with their status
reqscan list📋 Command Reference
| Command | Description |
|---------|-------------|
| check [dir] | List missing, present, and unused packages |
| install | Install all missing packages found by check |
| clean | Remove packages declared but never imported |
| fix | Run install + clean in one command |
| audit | Full dependency health report with score |
| list | Show all dependencies with status |
🚩 Available Flags
| Flag | Description | Commands |
|------|-------------|----------|
| --json | Output machine-readable JSON | check, audit, list |
| --save-dev | Install missing packages as devDependencies | install, fix |
| --dry-run | Preview changes without executing | install, clean, fix |
| --force | Skip confirmation prompt | clean, fix |
📤 Example Outputs
reqscan check
📦 Project: my-app
──────────────────────────────────────────────────
Summary
Total imports found : 9
Declared in pkg.json : 4
Already installed : 3
Missing (not declared): 2
❌ Missing Packages (not in package.json)
──────────────────────────────────────────────────
✗ axios
✗ uuid
💡 Run this to install all missing packages:
npm install axios uuid
✅ Already Declared Packages
──────────────────────────────────────────────────
✓ express ^4.18.0
✓ mongoose ^7.0.0
✓ dotenv ^16.0.0
⚠️ Declared but NOT imported in source (possibly unused)
──────────────────────────────────────────────────
~ jestreqscan audit
🏥 Dependency Health Report
──────────────────────────────────────────────────
Health Score : 75%
Files Scanned : 12
Total Imports : 8
Declared : 6
✓ Present : 6
✗ Missing : 2
~ Unused declared : 1
📋 package.json Breakdown
──────────────────────────────────────────────────
dependencies : 4
devDependencies : 2
peerDependencies : 0
optionalDependencies : 0
💡 Recommendations
──────────────────────────────────────────────────
→ Run reqscan install to install 2 missing package(s).
→ Run reqscan clean to remove 1 unused package(s).reqscan list
📋 All Dependencies with Status
──────────────────────────────────────────────────
✓ axios ^1.6.0 present
✗ date-fns missing
✓ express ^4.18.0 present
~ jest ^29.0.0 unused
Legend: ✓ present ✗ missing ~ declared but unused🛠️ How It Works
- Scans all
.js/.ts/.jsx/.tsx/.mjs/.cjsfiles (skipsnode_modules,dist,.next, etc.) - Extracts package names from all import styles:
require('pkg')import x from 'pkg'import type { T } from 'pkg'import('pkg')(dynamic)require.resolve('pkg')export { x } from 'pkg'import 'pkg'(side-effect)
- Strips comments before scanning so commented-out imports are ignored
- Filters out Node.js built-ins (
fs,path,http,node:*, etc.) - Compares against
package.json(all dependency types) - Reports and optionally acts on findings
🔧 Programmatic API
const { scanProject } = require('reqscan');
const result = await scanProject('/path/to/project');
console.log(result.missing); // ['axios', 'uuid']
console.log(result.present); // ['express', 'mongoose']
console.log(result.unused); // ['jest']
console.log(result.allImports); // all detected package names (sorted)
console.log(result.declared); // all declared package names (sorted)
console.log(result.scannedFiles); // list of files scanned
console.log(result.targetDir); // resolved project directoryReturn Value
| Field | Type | Description |
|-------|------|-------------|
| projectName | string | Name from package.json |
| allImports | string[] | All unique packages found in source (sorted) |
| declared | string[] | All packages in package.json (sorted) |
| missing | string[] | Imported but not declared |
| present | string[] | Imported AND declared |
| unused | string[] | Declared but never imported |
| scannedFiles | string[] | All files that were scanned |
| packageJson | object\|null | Parsed package.json content |
| targetDir | string | Resolved absolute path to the project root |
🧪 Running Tests
node test/test.js🗺️ Roadmap
- [ ]
reqscan outdated— Check for newer package versions - [ ]
reqscan upgrade— Update all outdated packages - [ ] Configuration file (
.reqscanrc) - [ ] Monorepo / workspace support
- [x]
--save-dev,--dry-run,--force,--jsonflags (shipped in v1.1.0)
📄 License
MIT
