CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-npm-check

Check for outdated, incorrect, and unused dependencies in npm projects.

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

cli.mddocs/

Command Line Interface

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.

Capabilities

Basic Command

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 path

Usage 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 --debug

Interactive Update Mode

Provides an interactive interface for selectively updating packages.

-u, --update                 # Interactive update mode

Usage 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 -E

Features of interactive mode:

  • Navigate with arrow keys to select packages
  • Space bar to toggle package selection
  • Shows changelog links for informed decisions
  • Respects semver and package-lock.json constraints
  • Uses locally installed npm version for updates

Automated Update Mode

Updates all outdated packages without user interaction.

-y, --update-all             # Update all packages without prompting

Usage 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 -E

Scope Options

Control 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 detection

Usage 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 -s

Filtering Options

Control which packages to include or exclude from analysis.

-i, --ignore <glob>          # Ignore dependencies matching glob pattern
--specials <list>            # Include specific depcheck specials

Usage 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,babel

Installation Options

Control how packages are installed when updating.

-E, --save-exact             # Save exact versions instead of semver ranges

Usage Examples:

# Update with exact versions (no ^ or ~ prefixes)
npm-check -u -E

# Automated update with exact versions
npm-check -y -E

Output Options

Control 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 output

Usage 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-spinner

Environment Variables

Configure 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_modules

Usage 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 -g

Configuration File Support

npm-check supports configuration files for advanced depcheck options.

# Configuration files (in order of precedence):
.npmcheckrc
.npmcheckrc.json
.npmcheckrc.yml
.npmcheckrc.js

Configuration Example:

# .npmcheckrc
depcheck:
  ignoreMatches: 
    - "replace-in-file"
    - "snyk"
    - "sonarqube-scanner"
  ignoreDirs:
    - "build"
    - "dist"
  specials:
    - "webpack"
    - "babel"

Exit Codes

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 analysis

Usage 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 build

Common Workflows

Typical 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 -s

CI/CD Pipeline:

# Check for outdated dependencies (fail build if found)
npm-check --no-color --no-emoji

# Production-only check
npm-check -p --no-color

Global 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 -y

Project Maintenance:

# Find unused dependencies
npm-check

# Clean update with exact versions
npm-check -u -E

# Debug dependency issues
npm-check --debug

Install with Tessl CLI

npx tessl i tessl/npm-npm-check

docs

cli.md

index.md

programmatic-api.md

tile.json