CI-friendly dependency version threshold checker with configurable version drift limits and meaningful exit codes.
npm outdated has no exit codes or version threshold configuration. You can't automatically fail CI builds when dependencies drift too far from their intended versions.
Example scenario: Your team wants to ensure no production dependency is more than 2 minor versions behind the latest, to avoid unexpected breaking changes while staying current with security patches.
- ✅ Zero-config CI integration — just works in GitHub Actions, GitLab CI, Jenkins
- ✅ Semantic version thresholding — configure max allowed major/minor/patch drift
- ✅ Smart default policies — sensible defaults for different project types
- ✅ Human-friendly output — clear warnings about policy violations
- ✅ Multiple output formats — text, table, JSON, markdown
- ✅ Meaningful exit codes — CI can gate builds based on results
- ✅ Configurable — CLI options + config file support
- ✅ Transitive dependency checking — scans package-lock.json for indirect deps
- ✅ Built-in caching — avoids redundant registry requests
- ✅ TypeScript implementation
npm install -g npm-outdated-checkOr as a dev dependency:
npm install -D npm-outdated-checkCheck all dependencies with default thresholds (major=0, minor=2, patch=5):
npm-outdated-checkFail if any dependency is more than 1 major version behind:
npm-outdated-check --max-major 1 --max-minor 5Check only production dependencies:
npm-outdated-check --dep prodnpm-outdated-check --format jsonnpm-outdated-check --format markdownOutput looks like:
## Dependency Check
❌ **2 violation(s)** found out of 15 dependencies.
| Package | Current | Latest | Type | Major | Minor | Patch |
|---------|---------|--------|------|-------|-------|-------|
| react | `^18.0.0` | `19.0.0` | prod | **1** ⚠️ | 0 | 0 |
| lodash | `^4.17.0` | `4.17.21` | prod | 0 | 0 | **21** ⚠️ |
_Thresholds: major=0, minor=2, patch=5_Create .npm-outdated-check.json in your project root:
{
"maxMajor": 0,
"maxMinor": 2,
"maxPatch": 5,
"include": ["prod", "dev"],
"exclude": ["typescript"],
"registry": "https://registry.npmjs.org",
"format": "text"
}| Option | Default | Description |
|---|---|---|
--max-major <n> |
0 | Maximum major version drift |
--max-minor <n> |
2 | Maximum minor version drift |
--max-patch <n> |
5 | Maximum patch version drift |
--dep <types> |
both | Include dependencies (prod, dev, both) |
--exclude <pkgs> |
- | Exclude packages (comma-separated) |
--registry <url> |
https://registry.npmjs.org | npm registry URL |
--format <fmt> |
text | Output format (text, table, json, markdown) |
--config <path> |
- | Path to config file |
--path <dir> |
cwd | Project directory (alternative to running from project root) |
--verbose |
false | Verbose output (shows cache hits, fetch progress, configuration details) |
--fail-on-any |
true | Exit with code 1 if any violations found (use --no-fail-on-any for report-only mode) |
--only-violations |
false | Show only violating packages (omits totalChecked count in output) |
--transitive |
true | Include transitive dependencies from package-lock.json |
--cache-ttl <ms> |
3600000 | Cache time-to-live in milliseconds (default: 1 hour, set 0 to disable) |
--disable-cache |
false | Disable caching completely (equivalent to --cache-ttl 0) |
0: No violations found — build passes1: Violations found — dependencies exceed thresholds2: Configuration errors3: Network/registry errors
"Error: Registry hostname not allowed for security"
- This is a security feature that restricts registry URLs to known safe domains
- Use official npm registry:
https://registry.npmjs.org - For private registries, make sure they're on a trusted domain
"Configuration errors" exit code 2
- Check your
.npm-outdated-check.jsonfor invalid JSON format - Verify registry URLs are properly formatted
- Ensure exclude patterns are valid npm package names
"Network/registry errors" exit code 3
- Check your internet connection
- Verify the registry URL is accessible
- Use
--verboseflag for more detailed error information - Private registries may require authentication (not currently supported)
- Enable caching by default (1-hour TTL) for faster repeated checks
- Use
--excludepatterns to skip known stable packages - For large projects, the
--transitiveflag may increase check time - Use
--disable-cacheonly when you need absolute latest version data
name: Dependency Check
on: [push, pull_request]
jobs:
outdated-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '18'
- run: npm install
- run: npx npm-outdated-check --max-minor 3dependency-check:
stage: test
script:
- npm install
- npx npm-outdated-check --max-major 0 --max-minor 2stage('Dependency Check') {
steps {
sh 'npm install'
sh 'npx npm-outdated-check --dep prod --max-minor 2 || exit 1'
}
}import { OutdatedChecker, Formatter, ConfigLoader } from 'npm-outdated-check';
const config = await ConfigLoader.load();
const checker = new OutdatedChecker(config);
const { violations } = await checker.check();
const formatter = new Formatter(config);
console.log(formatter.format({ violations, totalChecked: 10, passed: true, config }));
const exitCode = checker.getExitCode(violations);
process.exit(exitCode);Place .npm-outdated-check.json in your project root:
{
"maxMajor": 0,
"maxMinor": 2,
"maxPatch": 5,
"include": ["prod", "dev"],
"exclude": ["@types/*"],
"registry": "https://registry.npmjs.org",
"format": "table"
}| Feature | npm-outdated-check |
npm outdated |
npm-check-updates |
depcheck |
renovate |
|---|---|---|---|---|---|
| Version drift thresholds | ✅ Configurable per major/minor/patch | ❌ | ❌ | ❌ | ✅ (but complex) |
| CI exit codes | ✅ Meaningful (0–3) | ✅ (0/1 only) | ❌ | ✅ | ❌ |
| Config file | ✅ .npm-outdated-check.json |
❌ | ✅ | ✅ | ✅ (renovate.json) |
| Output formats | Text, table, JSON, markdown | Text only | Text, JSON | Text, JSON | Dashboard |
| Markdown for PR comments | ✅ Built-in | ❌ | ❌ | ❌ | ✅ (via bot) |
| Exclude patterns | ✅ Globs (@types/*) |
❌ | ✅ | ✅ | ✅ |
| Registry caching | ✅ Built-in | ❌ | ❌ | N/A | ✅ |
| Setup time | <2 min | 0 min | <2 min | <2 min | 30+ min |
| Use case | CI threshold gate | Quick manual check | Bulk update | Find unused deps | Auto-merge PRs |
Contributions welcome! Please read CONTRIBUTING.md for details.
MIT © Sulthon
- npm-check-updates — updates package.json dependencies
- npm outdated — built-in outdated check
- depcheck — checks for unused dependencies