Check for outdated, incorrect, and unused dependencies in npm projects.
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
The npm-check CLI provides an interactive and automated interface for analyzing and updating npm dependencies. It supports both local project analysis and global package management.
The primary command-line interface for npm-check.
npm-check [path] [options]
# Basic usage
npm-check # Analyze current directory
npm-check ./my-project # Analyze specific directory
npm-check /path/to/project # Analyze absolute pathUsage Examples:
# Check current directory for outdated and unused packages
npm-check
# Check a specific project directory
npm-check ./my-react-app
# Check with verbose output for debugging
npm-check --debugProvides an interactive interface for selectively updating packages.
-u, --update # Interactive update modeUsage Examples:
# Interactive update of local packages
npm-check -u
# Interactive update of global packages
npm-check -g -u
# Interactive update with exact versions
npm-check -u -EFeatures of interactive mode:
Updates all outdated packages without user interaction.
-y, --update-all # Update all packages without promptingUsage Examples:
# Update all local packages automatically
npm-check -y
# Update all global packages automatically
npm-check -g -y
# Update all with exact versions
npm-check -y -EControl which types of dependencies to analyze and update.
-g, --global # Check global modules
-p, --production # Skip devDependencies
-d, --dev-only # Only check devDependencies
-s, --skip-unused # Skip unused package detectionUsage Examples:
# Check only globally installed packages
npm-check -g
# Check only production dependencies (ignore devDependencies)
npm-check -p
# Check only development dependencies (ignore dependencies)
npm-check -d
# Skip the unused package analysis (faster execution)
npm-check -s
# Combined: interactive update of global packages, skip unused check
npm-check -g -u -sControl which packages to include or exclude from analysis.
-i, --ignore <glob> # Ignore dependencies matching glob pattern
--specials <list> # Include specific depcheck specialsUsage Examples:
# Ignore all babel-related packages
npm-check -i "babel-*"
# Ignore multiple patterns (use quotes for complex patterns)
npm-check -i "@types/*,eslint-*"
# Include webpack config in unused package detection
npm-check --specials=webpack
# Include multiple specials
npm-check --specials=bin,webpack,babelControl how packages are installed when updating.
-E, --save-exact # Save exact versions instead of semver rangesUsage Examples:
# Update with exact versions (no ^ or ~ prefixes)
npm-check -u -E
# Automated update with exact versions
npm-check -y -EControl the appearance and verbosity of output.
--no-color # Disable colored output
--no-emoji # Disable emoji in output
--no-spinner # Disable loading spinners
--debug # Enable debug outputUsage Examples:
# Plain text output without colors or emoji (good for CI)
npm-check --no-color --no-emoji
# Debug mode with detailed output
npm-check --debug
# Quiet mode without spinners (good for scripting)
npm-check --no-spinnerConfigure npm-check behavior through environment variables.
# Set preferred package manager
export NPM_CHECK_INSTALLER=pnpm
export NPM_CHECK_INSTALLER=yarn
export NPM_CHECK_INSTALLER=npm
# Override global node_modules path
export NODE_PATH=/custom/path/to/node_modulesUsage Examples:
# Use pnpm for updates
NPM_CHECK_INSTALLER=pnpm npm-check -u
# Use yarn for updates
NPM_CHECK_INSTALLER=yarn npm-check -u
# Dry run using echo (for testing)
NPM_CHECK_INSTALLER=echo npm-check -u
# Custom global modules path
NODE_PATH=/usr/local/lib/node_modules npm-check -gnpm-check supports configuration files for advanced depcheck options.
# Configuration files (in order of precedence):
.npmcheckrc
.npmcheckrc.json
.npmcheckrc.yml
.npmcheckrc.jsConfiguration Example:
# .npmcheckrc
depcheck:
ignoreMatches:
- "replace-in-file"
- "snyk"
- "sonarqube-scanner"
ignoreDirs:
- "build"
- "dist"
specials:
- "webpack"
- "babel"npm-check returns different exit codes based on analysis results.
# Exit codes:
0 # All packages are up to date and in use
1 # Outdated packages or unused packages found
1 # Error occurred during analysisUsage Examples:
# Use in CI/CD pipelines
npm-check
if [ $? -ne 0 ]; then
echo "Dependencies need attention"
exit 1
fi
# Combined with other commands
npm-check && npm test && npm run buildTypical usage patterns for different scenarios.
Development Workflow:
# Daily dependency check
npm-check
# Weekly interactive update
npm-check -u
# Pre-commit check (skip unused for speed)
npm-check -sCI/CD Pipeline:
# Check for outdated dependencies (fail build if found)
npm-check --no-color --no-emoji
# Production-only check
npm-check -p --no-colorGlobal Package Management:
# Check global packages
npm-check -g
# Update global packages interactively
npm-check -g -u
# Update all global packages including npm itself
npm-check -g -yProject Maintenance:
# Find unused dependencies
npm-check
# Clean update with exact versions
npm-check -u -E
# Debug dependency issues
npm-check --debugInstall with Tessl CLI
npx tessl i tessl/npm-npm-check