or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

cli.mdindex.mdprogrammatic-api.md
tile.json

tessl/npm-npm-check

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

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/npm-check@6.0.x

To install, run

npx @tessl/cli install tessl/npm-npm-check@6.0.0

index.mddocs/

npm-check

npm-check is a comprehensive Node.js library and command-line tool that analyzes npm projects to identify outdated, incorrect, and unused dependencies. It provides an interactive CLI interface for safely updating packages, supports both local and global dependency checking, and works with public and private npm registries.

Package Information

  • Package Name: npm-check
  • Package Type: npm
  • Language: JavaScript (Node.js)
  • Installation: npm install -g npm-check or npm install npm-check

Core Imports

const npmCheck = require('npm-check');

For TypeScript:

import npmCheck from 'npm-check';

Basic Usage

Programmatic API

const npmCheck = require('npm-check');

// Basic usage - check current directory
npmCheck()
  .then(currentState => {
    const packages = currentState.get('packages');
    packages.forEach(pkg => {
      console.log(`${pkg.moduleName}: ${pkg.installed} -> ${pkg.latest}`);
    });
  });

// With options
npmCheck({
  global: false,
  skipUnused: false,
  ignoreDev: false,
  cwd: './my-project'
})
  .then(currentState => {
    // Process results
    const outdatedPackages = currentState.get('packages')
      .filter(pkg => pkg.bump && !pkg.notInstalled);
  });

Command Line Interface

# Check current directory
npm-check

# Interactive update mode
npm-check -u

# Check global packages
npm-check -g

# Update all packages without prompting
npm-check -y

# Check only production dependencies
npm-check -p

# Skip unused dependency check
npm-check -s

Architecture

npm-check is built around several key components:

  • State Management: Central state object that tracks all analysis data and configuration
  • Input Analysis: Modules that analyze package.json, installed packages, and registry data
  • Output Formatting: Different output modes (static, interactive, batch update)
  • CLI Interface: Command-line wrapper that provides user-friendly interface
  • Dependency Detection: Integration with depcheck for unused dependency analysis

Capabilities

Programmatic API

Core programmatic interface for integrating npm-check functionality into other tools and scripts.

function npmCheck(options?: NpmCheckOptions): Promise<CurrentState>;

interface NpmCheckOptions {
  global?: boolean;
  update?: boolean;
  updateAll?: boolean;
  skipUnused?: boolean;
  devOnly?: boolean;
  ignoreDev?: boolean;
  cwd?: string;
  saveExact?: boolean;
  currentState?: Object;
  ignore?: string | string[];
  specials?: string;
  debug?: boolean;
  emoji?: boolean;
  spinner?: boolean;
  installer?: 'npm' | 'pnpm' | 'yarn' | 'ied' | 'auto';
}

interface CurrentState {
  get(key: string): any;
  set(key: string, value: any): void;
  all(): Object;
  inspectIfDebugMode(): void;
}

Programmatic API

Command Line Interface

Full-featured CLI for interactive and automated dependency management workflows.

npm-check [path] [options]

Options:
  -u, --update          Interactive update
  -y, --update-all      Update all without prompting  
  -g, --global          Check global modules
  -s, --skip-unused     Skip unused package check
  -p, --production      Skip devDependencies
  -d, --dev-only        Only check devDependencies
  -i, --ignore <glob>   Ignore dependencies by glob
  -E, --save-exact      Save exact versions
  --specials <list>     Depcheck specials to include
  --no-color           Disable color output
  --no-emoji           Disable emoji output
  --debug              Enable debug output

Command Line Interface

Types

interface PackageInfo {
  moduleName: string;
  homepage: string;
  regError: any;
  pkgError: any;
  latest: string;
  installed: string;
  isInstalled: boolean;
  notInstalled: boolean;
  packageWanted: string;
  packageJson: string;
  devDependency: boolean;
  usedInScripts: string[] | undefined;
  mismatch: boolean;
  semverValid: string;
  easyUpgrade: boolean;
  bump: 'patch' | 'minor' | 'major' | 'prerelease' | 'build' | 'nonSemver' | null;
  unused: boolean;
}

type StateKey = 
  | 'packages'               // Array of PackageInfo objects
  | 'debug'                 // Debug mode status
  | 'global'                // Global mode status
  | 'cwd'                   // Current working directory
  | 'cwdPackageJson'        // Parsed package.json object
  | 'emoji'                 // Emoji mode status
  | 'globalPackages'        // Global packages data
  | 'unusedDependencies'    // Unused dependencies array
  | 'missingFromPackageJson' // Missing packages object
  | 'update'                // Update mode status
  | 'updateAll'             // Update all mode status
  | 'skipUnused'            // Skip unused check status
  | 'devOnly'               // Dev only mode status
  | 'ignoreDev'             // Ignore dev dependencies status
  | 'saveExact'             // Save exact versions status
  | 'specials'              // Depcheck specials
  | 'spinner'               // Spinner enabled status
  | 'installer'             // Package installer to use
  | 'ignore';               // Ignore patterns for dependencies