npm-check-updates
TypeScript icon, indicating that this package has built-in type declarations

22.2.3 • Public • Published

npm-check-updates

npm version Build Status

npm-check-updates upgrades your package.json dependencies to the latest versions, ignoring specified versions.

  • maintains existing semantic versioning policies, i.e. "react": "^17.0.2" to "react": "^18.3.1".
  • only modifies package.json file. Run npm install to update your installed packages and package-lock.json.
  • sensible defaults, but highly customizable
  • compatible with npm, yarn, pnpm, deno, and bun
  • CLI and module usage
  • Pure ESM architecture with dual-build support (ESM/CJS)

⚠️ v21.0.0 Breaking Changes (ESM Migration)

npm-check-updates is now a dual ESM/CJS module. If you use a .ncurc.js config or programmatic imports, please see the ESM Migration Guide in the CHANGELOG for required updates.

example output

$${\color{red}Red}$$ major upgrade (and all major version zero)
$${\color{cyan}Cyan}$$ minor upgrade
$${\color{green}Green}$$ patch upgrade

Requirements

  • Node.js: ^20.19.0 || ^22.12.0 || >=24.0.0
  • npm: >=10.0.0

npm-check-updates v21+ requires modern Node.js and npm versions to support native ESM and Vite 8's Rolldown bundler.

Installation

Install globally to use npm-check-updates or the shorter ncu:

npm install -g npm-check-updates

Or run with npx (only the long form is supported):

npx npm-check-updates

Usage

Check the latest versions of all project dependencies:

$ ncu
Checking package.json
[====================] 5/5 100%

 eslint             7.32.0  →    8.0.0
 prettier           ^2.7.1  →   ^3.0.0
 svelte            ^3.48.0  →  ^3.51.0
 typescript         >3.0.0  →   >4.0.0
 untildify          <4.0.0  →   ^4.0.0
 webpack               4.x  →      5.x

Run ncu -u to upgrade package.json

Upgrade a project's package file:

Make sure your package file is in version control and all changes have been committed. This will overwrite your package file.

$ ncu -u
Upgrading package.json
[====================] 1/1 100%

 express           4.12.x  →   4.13.x

Run npm install to install new versions.

$ npm install      # update installed packages and package-lock.json

Check global packages:

ncu -g

Interactive Mode

Choose which packages to update in interactive mode:

ncu --interactive
ncu -i

ncu --interactive

Combine with --format group for a truly luxe experience:

ncu --interactive --format group

Keys

  • Select a package
  • Space Toggle selection
  • a Toggle all
  • Enter Upgrade

Filter packages

Filter packages using the --filter option or adding additional cli arguments:

# upgrade only mocha
ncu mocha
ncu -f mocha
ncu --filter mocha

# upgrade only chalk, mocha, and react
ncu chalk mocha react
ncu chalk, mocha, react
ncu -f "chalk mocha react"

Filter with wildcards or regex:

# upgrade packages that start with "react-"
ncu react-*
ncu "/^react-.*$/"

Exclude specific packages with the --reject option or prefixing a filter with !. Supports strings, wildcards, globs, comma-or-space-delimited lists, and regex:

# upgrade everything except nodemon
ncu \!nodemon
ncu -x nodemon
ncu --reject nodemon

# upgrade packages that do not start with "react-".
ncu \!react-*
ncu '/^(?!react-).*$/' # mac/linux
ncu "/^(?!react-).*$/" # windows

Advanced filters: filter, filterResults, filterVersion

How dependency updates are determined

  • Direct dependencies are updated to the latest stable version:
    • 2.0.12.2.0
    • 1.21.3
    • 0.1.01.0.1
  • Range operators are preserved and the version is updated:
    • ^1.2.0^2.0.0
    • 1.x2.x
    • >0.2.0>0.3.0
  • "Less than" is replaced with a wildcard:
    • <2.0.0^3.0.0
    • 1.0.0 < 2.0.0^3.0.0
  • "Any version" is preserved:
    • **
  • Prerelease versions are ignored by default.
    • Use --pre to include prerelease versions (e.g. alpha, beta, build1235)
  • Choose what level to upgrade to:
    • With --target semver, update according to your specified semver version ranges:
      • ^1.1.0^1.9.99
    • With --target minor, strictly update the patch and minor versions (including major version zero):
      • 0.1.00.2.1
    • With --target patch, strictly update the patch version (including major version zero):
      • 0.1.00.1.2
    • With --target @next, update to the version published on the next tag:
      • 0.1.0 -> 0.1.1-next.1

Options

Options are merged with the following precedence:

  1. Command line options
  2. Local Config File (current working directory)
  3. Project Config File (next to package.json)
  4. User Config File ($HOME)

Options that take no arguments can be negated by prefixing them with --no-, e.g. --no-peer.

--cache Cache versions to a local cache file. Default --cacheFile is ~/.ncu-cache.json and default --cacheExpiration is 10 minutes.
--cacheClear Clear the default cache, or the cache file specified by --cacheFile.
--cacheExpiration <min> Cache expiration in minutes. Only works with --cache. (default: 10)
--cacheFile <path> Filepath for the cache file. Only works with --cache. (default: "~/.ncu-cache.json")
--color Force color in terminal.
--concurrency <n> Max number of concurrent HTTP requests to registry. (default: 8)
--configFileName <s> Config file name. (default: .ncurc or .ncurc.{json,yaml,yml,js,mjs,cjs})
--configFilePath <path> Directory of .ncurc config file. (default: directory of packageFile)
-c, --cooldown <period> Sets a minimum age for package versions to be considered for upgrade. Accepts a number (days) or a string with a unit: "7d" (days), "12h" (hours), "30m" (minutes). Reduces the risk of installing newly published, potentially compromised packages.
--cwd <path> Working directory in which npm will be executed.
--deep Run recursively in current working directory. Alias of (--packageFile '**/package.json').
--dep <value> Check one or more sections of dependencies only: dev, optional, peer, prod, or packageManager (comma-delimited). (default: ["prod","dev","optional","packageManager"])
--deprecated Include deprecated packages. Use --no-deprecated to exclude deprecated packages (20–25% slower). (default: true)
-d, --doctor Iteratively installs upgrades and runs tests to identify breaking upgrades. Requires -u to execute.
--doctorInstall <command> Specifies the install script to use in doctor mode. (default: npm install or the equivalent for your package manager)
--doctorTest <command> Specifies the test script to use in doctor mode. (default: npm test)
--enginesNode Include only packages that satisfy engines.node as specified in the package file.
-e, --errorLevel <n> Set the error level. 1: exits with error code 0 if no errors occur. 2: exits with error code 0 if no packages need updating (useful for continuous integration). (default: 1)
-f, --filter <p> Include only package names matching the given string, wildcard, glob, comma-or-space-delimited list, /regex/, or predicate function.
filterResults <fn> Filters results based on a user provided predicate function after fetching new versions.
--filterVersion <p> Filter on package version using comma-or-space-delimited list, /regex/, or predicate function.
--format <value> Modify the output formatting or show additional information. Specify one or more comma-delimited values: dep, group, ownerChanged, repo, time, lines, installedVersion, cooldown. (default: [])
-g, --global Check global packages instead of in the current project.
groupFunction <fn> Customize how packages are divided into groups when using --format group.
--install <value> Control the auto-install behavior: always, never, prompt. (default: "prompt")
-i, --interactive Enable interactive prompts for each dependency; implies -u unless one of the json options are set.
-j, --jsonAll Output new package file instead of human-readable message.
--jsonDeps Like jsonAll but only lists dependencies, devDependencies, optionalDependencies, etc of the new package data.
--jsonUpgraded Output upgraded dependencies in json.
-l, --loglevel <n> Amount to log: silent, error, minimal, warn, info, verbose, silly. (default: "warn")
--mergeConfig Merges nested configs with the root config file for --deep or --packageFile options. (default: false)
-m, --minimal Do not upgrade newer versions that are already satisfied by the version range according to semver.
--packageData <value> Package file data (you can also use stdin).
--packageFile <path|glob> Package file(s) location. (default: ./package.json)
-p, --packageManager <s> npm, yarn, pnpm, deno, bun, staticRegistry (default: npm).
--peer Check peer dependencies of installed packages and filter updates to compatible versions.
--pre <n> Include prerelease versions, e.g. -alpha.0, -beta.5, -rc.2. Automatically set to 1 when --target is newest or greatest, or when the current version is a prerelease. (default: 0)
--prefix <path> Current working directory of npm.
-r, --registry <uri> Specify the registry to use when looking up package versions.
--registryType <type> Specify whether --registry refers to a full npm registry or a simple JSON file or url: npm, json. (default: npm)
-x, --reject <p> Exclude packages matching the given string, wildcard, glob, comma-or-space-delimited list, /regex/, or predicate function.
--rejectVersion <p> Exclude package.json versions using comma-or-space-delimited list, /regex/, or predicate function.
--removeRange Remove version ranges from the final package version.
--retry <n> Number of times to retry failed requests for package info. (default: 3)
--root Runs updates on the root project in addition to specified workspaces. Only allowed with --workspace or --workspaces. (default: true)
-s, --silent Don't output anything. Alias for --loglevel silent.
--stdin Read package.json from stdin.
-t, --target <value> Determines the version to upgrade to: latest, newest, greatest, minor, patch, semver, @[tag], or [function]. (default: latest)
--timeout <ms> Global timeout in milliseconds. (default: no global timeout and 30 seconds per npm-registry-fetch)
-u, --upgrade Overwrite package file with upgraded versions instead of just outputting to console.
--verbose Log additional information for debugging. Alias for --loglevel verbose.
--workspace <s> Run on one or more specified workspaces. Add --no-root to exclude the root project. (default: [])
-w, --workspaces Run on all workspaces. Add --no-root to exclude the root project.

Advanced Options

Some options have advanced usage, or allow per-package values by specifying a function in your .ncurc.js file.

Run ncu --help [OPTION] to view advanced help for a specific option, or see below:

cooldown

Usage:

ncu --cooldown [period]
ncu -c [period]

The cooldown option helps protect against supply chain attacks by requiring package versions to be published at least the given amount of time before considering them for upgrade.

The value can be a plain number (days) or a string with a unit suffix:

--cooldown 7       7 days
--cooldown 7d      7 days (same as above)
--cooldown 12h     12 hours
--cooldown 30m     30 minutes

With the default --target latest, if the latest dist-tag version is within the cooldown window, ncu falls back to the greatest version that passes the cooldown threshold. To instead skip the package entirely (strict behaviour), use --target "@latest".

Example:

Let's examine how cooldown works with a package that has these versions available:

1.0.0          Released 7 days ago    (initial version)
1.1.0          Released 6 days ago    (minor update)
1.1.1          Released 5 days ago    (patch update)
1.2.0          Released 5 days ago    (minor update)
2.0.0-beta.1   Released 5 days ago    (beta release)
1.2.1          Released 4 days ago    (patch update)
1.3.0          Released 4 days ago    (minor update) [latest]
2.0.0-beta.2   Released 3 days ago    (beta release)
2.0.0-beta.3   Released 2 days ago    (beta release) [beta]

With default target (latest):

$ ncu --cooldown 5

Falls back to 1.2.0 because:

  • Latest version (1.3.0) is only 4 days old (within 5-day cooldown)
  • 1.2.0 is the greatest version that is at least 5 days old

With @latest strict target:

$ ncu --cooldown 5 --target @latest

No update will be suggested because:

  • Latest version (1.3.0) is only 4 days old
  • Cooldown requires versions to be at least 5 days old
  • @latest is strict: no fallback to older versions

With @beta/@tag target:

$ ncu --cooldown 3 --target @beta

No update will be suggested because:

  • Current beta (2.0.0-beta.3) is only 2 days old
  • Cooldown requires versions to be at least 3 days old
  • Use --cooldown 2 or lower to allow this update

With other targets:

$ ncu --cooldown 5 --target greatest|newest|minor|patch|semver

Each target will select the best version that is at least 5 days old:

greatest → 1.2.0        (highest version number outside cooldown)
newest   → 2.0.0-beta.1 (most recently published version outside cooldown)
minor    → 1.2.0        (highest minor version outside cooldown)
patch    → 1.1.1        (highest patch version outside cooldown)

You can also provide a custom function in your .ncurc.js file or when importing npm-check-updates as a module.

⚠️ The predicate function is only available in .ncurc.js or when importing npm-check-updates as a module, not on the command line. To convert a JSON config to a JS config, follow the instructions at https://github.com/raineorshine/npm-check-updates#config-functions.

/** Set cooldown to 3 days but skip it for `@my-company` packages.
  @param packageName     The name of the dependency.
  @returns               Cooldown days restriction for given package.
*/
cooldown: packageName => (packageName.startsWith('@my-company') ? 0 : 3)

Package Manager Configurations

If --cooldown is not set explicitly, ncu automatically reads the cooldown configuration from your package manager's config file:

npm Reads `min-release-age` from `.npmrc`.
yarn Reads `npmMinimalAgeGate` from `.yarnrc.yml`, excluding packages matched by `npmPreapprovedPackages`.
pnpm Reads `minimumReleaseAge` from `pnpm-workspace.yaml`, excluding packages matched by `minimumReleaseAgeExclude`.

Cooldown Formatting

When using --format cooldown alongside the --cooldown option, ncu will show a list of packages that were skipped due to the --cooldown threshold.

Example:

ncu --format cooldown --cooldown 7

Output:

Skipped due to 7-day cooldown
 @typescript-eslint/parser  ^8.50.0  →  ^8.59.1      5 days ago
 eslint                     ^10.0.1  →  ^10.3.0      1 day ago

doctor

Usage:

ncu --doctor -u
ncu --no-doctor
ncu -du

Iteratively installs upgrades and runs your project's tests to identify breaking upgrades. Reverts broken upgrades and updates package.json with working upgrades.

Requires -u to execute (modifies your package file, lock file, and node_modules)

To be more precise:

  1. Runs npm install and npm test to ensure tests are currently passing.
  2. Runs ncu -u to optimistically upgrade all dependencies.
  3. If tests pass, hurray!
  4. If tests fail, restores package file and lock file.
  5. For each dependency, install upgrade and run tests.
  6. Prints broken upgrades with test error.
  7. Saves working upgrades to package.json.

Additional options:

--doctorInstall specify a custom install script (default: `npm install` or `yarn`)
--doctorTest specify a custom test script (default: `npm test`)

Example:

$ ncu --doctor -u
Running tests before upgrading
npm install
npm run test
Upgrading all dependencies and re-running tests
ncu -u
npm install
npm run test
Tests failed
Identifying broken dependencies
npm install
npm install --no-save react@16.0.0
npm run test
  ✓ react 15.0.0 → 16.0.0
npm install --no-save react-redux@7.0.0
npm run test
  ✗ react-redux 6.0.0 → 7.0.0

/projects/myproject/test.js:13
  throw new Error('Test failed!')
  ^

npm install --no-save react-dnd@11.1.3
npm run test
  ✓ react-dnd 10.0.0 → 11.1.3
Saving partially upgraded package.json

filter

Usage:

ncu --filter [p]
ncu -f [p]

Include only package names matching the given string, wildcard, glob, comma-or-space-delimited list, /regex/, or predicate function. Only included packages will be checked with --peer.

--filter runs before new versions are fetched, in contrast to --filterResults which runs after.

You can also specify a custom function in your .ncurc.js file, or when importing npm-check-updates as a module.

⚠️ The predicate function is only available in .ncurc.js or when importing npm-check-updates as a module, not on the command line. To convert a JSON config to a JS config, follow the instructions at https://github.com/raineorshine/npm-check-updates#config-functions.

/**
  @param name     The name of the dependency.
  @param semver   A parsed Semver array of the current version.
    (See: https://git.coolaj86.com/coolaj86/semver-utils.js#semverutils-parse-semverstring)
  @returns        True if the package should be included, false if it should be excluded.
*/
filter: (name, semver) => {
  if (name.startsWith('@myorg/')) {
    return false
  }
  return true
}

filterResults

Filters results based on a user provided predicate function after fetching new versions.

filterResults runs after new versions are fetched, in contrast to filter, reject, filterVersion, and rejectVersion, which run before. This allows you to exclude upgrades with filterResults based on how the version has changed (e.g. a major version change).

⚠️ The predicate function is only available in .ncurc.js or when importing npm-check-updates as a module, not on the command line. To convert a JSON config to a JS config, follow the instructions at https://github.com/raineorshine/npm-check-updates#config-functions.

/** Exclude major version updates. Note this could also be achieved with --target semver.
  @param {string} packageName               The name of the dependency.
  @param {string} current                   Current version declaration (may be a range).
  @param {SemVer[]} currentVersionSemver    Current version declaration in semantic versioning format (may be a range).
  @param {string} upgraded                  Upgraded version.
  @param {SemVer} upgradedVersionSemver     Upgraded version in semantic versioning format.
  @returns {boolean}                        Return true if the upgrade should be kept; otherwise, it will be ignored.
*/
filterResults: (packageName, { current, currentVersionSemver, upgraded, upgradedVersionSemver }) => {
  const currentMajor = parseInt(currentVersionSemver[0]?.major, 10)
  const upgradedMajor = parseInt(upgradedVersionSemver?.major, 10)
  if (currentMajor && upgradedMajor) {
    return currentMajor >= upgradedMajor
  }
  return true
}

For the SemVer type definition, see: https://git.coolaj86.com/coolaj86/semver-utils.js#semverutils-parse-semverstring

filterVersion

Usage:

ncu --filterVersion [p]

Include only versions matching the given string, wildcard, glob, comma-or-space-delimited list, /regex/, or predicate function.

--filterVersion runs before new versions are fetched, in contrast to --filterResults which runs after.

You can also specify a custom function in your .ncurc.js file, or when importing npm-check-updates as a module.

⚠️ The predicate function is only available in .ncurc.js or when importing npm-check-updates as a module, not on the command line. To convert a JSON config to a JS config, follow the instructions at https://github.com/raineorshine/npm-check-updates#config-functions. This function is an alias for the filter option function.

/**
  @param name     The name of the dependency.
  @param semver   A parsed Semver array of the current version.
    (See: https://git.coolaj86.com/coolaj86/semver-utils.js#semverutils-parse-semverstring)
  @returns        True if the package should be included, false if it should be excluded.
*/
filterVersion: (name, semver) => {
  if (name.startsWith('@myorg/') && parseInt(semver[0]?.major) > 5) {
    return false
  }
  return true
}

format

Usage:

ncu --format [value]

Modify the output formatting or show additional information. Specify one or more comma-delimited values.

dep Prints the dependency type (dev, peer, optional) of each package.
group Groups packages by major, minor, patch, and major version zero updates.
homepage Displays links to the package's homepage if specified in its package.json.
installedVersion Prints the exact current version number instead of a range.
lines Prints name@version on separate lines. Useful for piping to npm install.
ownerChanged Shows if the package owner has changed.
repo Infers and displays links to the package's source code repository. Requires packages to be installed.
diff Display link to compare the changes between package versions.
time Shows the publish time of each upgrade.
cooldown Shows a list of packages that were skipped due to the --cooldown threshold.

groupFunction

Customize how packages are divided into groups when using --format group.

Only available in .ncurc.js or when importing npm-check-updates as a module, not on the command line. To convert a JSON config to a JS config, follow the instructions at https://github.com/raineorshine/npm-check-updates#config-functions.

/**
  @param name             The name of the dependency.
  @param defaultGroup     The predefined group name which will be used by default.
  @param currentSpec      The current version range in your package.json.
  @param upgradedSpec     The upgraded version range that will be written to your package.json.
  @param upgradedVersion  The upgraded version number returned by the registry.
  @returns                A predefined group name ('major' | 'minor' | 'patch' | 'majorVersionZero' | 'none') or a custom string to create your own group.
*/
groupFunction: (name, defaultGroup, currentSpec, upgradedSpec, upgradedVersion) => {
  if (name === 'typescript' && defaultGroup === 'minor') {
    return 'major'
  }
  if (name.startsWith('@myorg/')) {
    return 'My Org'
  }
  return defaultGroup
}

install

Usage:

ncu --install [value]

Default: prompt

Control the auto-install behavior.

always Runs your package manager's install command automatically after upgrading.
never Does not install and does not prompt.
prompt Shows a message after upgrading that recommends an install, but does not install. In interactive mode, prompts for install. (default)

packageManager

Usage:

ncu --packageManager [s]
ncu -p [s]

Specifies the package manager to use when looking up versions.

npm System-installed npm. Default.
yarn System-installed yarn. Automatically used if yarn.lock is present.
pnpm System-installed pnpm. Automatically used if pnpm-lock.yaml is present.
bun System-installed bun. Automatically used if bun.lock or bun.lockb is present.

peer

Usage:

ncu --peer
ncu --no-peer

Check peer dependencies of installed packages and filter updates to compatible versions.

Example:

The following example demonstrates how --peer works, and how it uses peer dependencies from upgraded modules.

The package ncu-test-peer-update has two versions published:

  • 1.0.0 has peer dependency "ncu-test-return-version": "1.0.x"
  • 1.1.0 has peer dependency "ncu-test-return-version": "1.1.x"

Our test app has the following dependencies:

"ncu-test-peer-update": "1.0.0",
"ncu-test-return-version": "1.0.0"

The latest versions of these packages are:

"ncu-test-peer-update": "1.1.0",
"ncu-test-return-version": "2.0.0"

With --peer:

ncu upgrades packages to the highest version that still adheres to the peer dependency constraints:

ncu-test-peer-update     1.0.0  →  1.1.0
ncu-test-return-version  1.0.0  →  1.1.0

Without --peer:

As a comparison: without using the --peer option, ncu will suggest the latest versions, ignoring peer dependencies:

ncu-test-peer-update     1.0.0  →  1.1.0
ncu-test-return-version  1.0.0  →  2.0.0

registryType

Usage:

ncu --registryType [type]

Specify whether --registry refers to a full npm registry or a simple JSON file.

npm Default npm registry
json Checks versions from a file or url to a simple JSON registry. Must include the `--registry` option.

Example:

// local file
$ ncu --registryType json --registry ./registry.json

// url
$ ncu --registryType json --registry https://api.mydomain/registry.json

// you can omit --registryType when the registry ends in .json
$ ncu --registry ./registry.json
$ ncu --registry https://api.mydomain/registry.json

registry.json:

{
  "prettier": "2.7.1",
  "typescript": "4.7.4"
}

reject

Usage:

ncu --reject [p]
ncu -x [p]

The inverse of --filter. Exclude package names matching the given string, wildcard, glob, comma-or-space-delimited list, /regex/, or predicate function. This will also exclude them from the --peer check.

--reject runs before new versions are fetched, in contrast to --filterResults which runs after.

You can also specify a custom function in your .ncurc.js file, or when importing npm-check-updates as a module.

⚠️ The predicate function is only available in .ncurc.js or when importing npm-check-updates as a module, not on the command line. To convert a JSON config to a JS config, follow the instructions at https://github.com/raineorshine/npm-check-updates#config-functions.

/**
  @param name     The name of the dependency.
  @param semver   A parsed Semver array of the current version.
    (See: https://git.coolaj86.com/coolaj86/semver-utils.js#semverutils-parse-semverstring)
  @returns        True if the package should be excluded, false if it should be included.
*/
reject: (name, semver) => {
  if (name.startsWith('@myorg/')) {
    return true
  }
  return false
}

rejectVersion

Usage:

ncu --rejectVersion [p]

The inverse of --filterVersion. Exclude versions matching the given string, wildcard, glob, comma-or-space-delimited list, /regex/, or predicate function.

--rejectVersion runs before new versions are fetched, in contrast to --filterResults which runs after.

You can also specify a custom function in your .ncurc.js file, or when importing npm-check-updates as a module.

⚠️ The predicate function is only available in .ncurc.js or when importing npm-check-updates as a module, not on the command line. To convert a JSON config to a JS config, follow the instructions at https://github.com/raineorshine/npm-check-updates#config-functions. This function is an alias for the reject option function.

/**
  @param name     The name of the dependency.
  @param semver   A parsed Semver array of the current version.
    (See: https://git.coolaj86.com/coolaj86/semver-utils.js#semverutils-parse-semverstring)
  @returns        True if the package should be excluded, false if it should be included.
*/
rejectVersion: (name, semver) => {
  if (name.startsWith('@myorg/') && parseInt(semver[0]?.major) > 5) {
    return true
  }
  return false
}

target

Usage:

ncu --target [value]
ncu -t [value]

Determines the version to upgrade to. (default: "latest")

greatest Upgrade to the highest version number published, regardless of release date or tag. Includes prereleases.
latest Upgrade to whatever the package's "latest" dist-tag points to. When used with --cooldown, falls back to the greatest version that passes the cooldown threshold if the latest is too recent. Use --target "@latest" for strict behaviour that skips the package instead. Excludes prereleases unless --pre is specified.
minor Upgrade to the highest minor version without bumping the major version.
newest Upgrade to the version with the most recent publish date, even if there are other version numbers that are higher. Includes prereleases.
patch Upgrade to the highest patch version without bumping the minor or major versions.
semver Upgrade to the highest version within the semver range specified in your package.json.
@[tag] Upgrade to the version published to a specific tag, e.g. 'next' or 'beta'.

e.g.

ncu --target semver

You can also specify a custom function in your .ncurc.js file, or when importing npm-check-updates as a module.

⚠️ The predicate function is only available in .ncurc.js or when importing npm-check-updates as a module, not on the command line. To convert a JSON config to a JS config, follow the instructions at https://github.com/raineorshine/npm-check-updates#config-functions.

/** Upgrade major version zero to the next minor version, and everything else to latest.
  @param name     The name of the dependency.
  @param semver   A parsed Semver object of the upgraded version.
    (See: https://git.coolaj86.com/coolaj86/semver-utils.js#semverutils-parse-semverstring)
  @returns        One of the valid target values (specified in the table above).
*/
target: (name, semver) => {
  if (parseInt(semver[0]?.major) === '0') return 'minor'
  return 'latest'
}

Config File

Add a .ncurc or .ncurc.{json,yaml,yml,js,mjs,cjs} file to your project directory to specify configuration information.

.ncurc without an extension can be in JSON or YAML format. For example:

.ncurc:

upgrade: true
filter: svelte
reject:
  - '@types/estree'
  - ts-node

.ncurc.json:

{
  "upgrade": true,
  "filter": "svelte",
  "reject": ["@types/estree", "ts-node"]
}

Options are merged with the following precedence:

  1. Command line options
  2. Local Config File (current working directory)
  3. Project Config File (next to package.json)
  4. User Config File ($HOME)

You can also specify a custom config file name or path using the --configFileName or --configFilePath command line options.

Config Functions

Some options offer more advanced configuration using a function definition. These include filter, filterVersion, filterResults, reject, rejectVersion, and groupFunction. To define these, use a JavaScript-based configuration file.

ESM (Recommended)

Rename your config to .ncurc.js (if using "type": "module") or .ncurc.mjs.

import { defineConfig } from 'npm-check-updates'

export default defineConfig({
  upgrade: true,
  filter: name => name.startsWith('@myorg/'),
})

CommonJS

Use the .ncurc.cjs extension or a standard .ncurc.js file (if useing "type": "commonjs").

const { defineConfig } = require('npm-check-updates')

module.exports = defineConfig({
  upgrade: true,
  filter: name => name.startsWith('@myorg/'),
})

Alternatively, if you prefer not to use the helper, you can use JSDoc for IntelliSense:

ESM (JSDoc)

/** @type {import('npm-check-updates').RcOptions} */
export default {
  upgrade: true,
  filter: name => name.startsWith('@myorg/'),
}

CommonJS (JSDoc)

/** @type {import('npm-check-updates').RcOptions} */
module.exports = {
  upgrade: true,
  filter: name => name.startsWith('@myorg/'),
}

JSON Schema

If you write .ncurc config files using json or yaml, you can add the JSON Schema to your IDE settings for completions.

e.g. for VS Code:

  "json.schemas": [
    {
      "fileMatch": [
        ".ncurc",
        ".ncurc.json",
      ],
      "url": "https://raw.githubusercontent.com/raineorshine/npm-check-updates/main/src/types/RunOptions.json"
    }
  ],
  "yaml.schemas": {
    "https://raw.githubusercontent.com/raineorshine/npm-check-updates/main/src/types/RunOptions.json": [
        ".ncurc.yml",
    ]
  },

Module/Programmatic Usage

npm-check-updates can be imported as a module in both ESM and CommonJS environments.

ESM (Recommended)

Use this for modern projects using "type": "module" in package.json or .mjs files.

import * as ncu from 'npm-check-updates'

const upgraded = await ncu.run({
  // Pass any cli option
  packageFile: '../package.json',
  upgrade: true,
  // Defaults:
  // jsonUpgraded: true,
  // silent: true,
})

console.log(upgraded) // { "mypackage": "^2.0.0", ... }

CommonJS

Use this for legacy projects using "type": "commonjs" or scripts using the .cjs extension.

const ncu = require('npm-check-updates')

// Since ncu.run() is an async function
ncu
  .run({
    packageFile: './package.json',
    upgrade: true,
  })
  .then(upgraded => {
    console.log(upgraded)
  })

Contributing

Contributions are happily accepted. I respond to all PR's and can offer guidance on where to make changes. For contributing tips see CONTRIBUTING.md.

Problems?

File an issue. Please search existing issues first.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
22.2.3123,362latest
17.1.4-07next

Version History

VersionDownloads (Last 7 Days)Published
22.2.3123,362
22.2.29,541
22.2.141,894
22.2.028,682
22.1.15,261
22.1.06,929
22.0.13,340
22.0.091
21.0.321,344
21.0.22,982
21.0.1184
21.0.0387
20.0.28,558
20.0.12,184
20.0.011,576
19.6.643,354
19.6.515,943
19.6.313,007
19.6.2155
19.6.114
19.6.04
19.5.0557
19.4.13,210
19.4.0890
19.3.214,004
19.3.141,753
19.3.0479
19.2.1906
19.2.09,486
19.1.29,194
19.1.12,341
19.1.0178
19.0.02,082
18.3.151,291
18.3.03,369
18.2.1295
18.2.016
18.1.1801
18.1.01,240
18.0.31,640
18.0.25,170
18.0.110,427
18.0.0338
17.1.1886,153
17.1.174
17.1.163,672
17.1.154,742
17.1.144,139
17.1.131,012
17.1.12778
17.1.115,595
17.1.103,056
17.1.91,734
17.1.8320
17.1.71
17.1.624
17.1.514
17.1.4277
17.1.4-07
17.1.32,537
17.1.267
17.1.12,395
17.1.0461
17.0.6442
17.0.516
17.0.42
17.0.3230
17.0.222
17.0.1606
17.0.0575
17.0.0-80
17.0.0-70
17.0.0-60
16.14.2071,602
16.14.20-00
16.14.19247
17.0.0-51
17.0.0-40
17.0.0-30
16.14.182,223
17.0.0-29
16.14.17347
17.0.0-1346
16.14.1661
17.0.0-014
16.14.151,829
16.14.141,149
16.14.1310
16.14.127,627
16.14.111,293
16.14.103
16.14.92
16.14.84
16.14.77
16.14.64,786
16.14.5510
16.14.4857
16.14.357
16.14.245
16.14.154
16.14.0176
16.13.45
16.13.3712
16.13.2246
16.13.145
16.13.018
16.12.370
16.12.2228
16.12.13
16.12.03
16.11.219
16.11.1322
16.11.01
16.10.1918
16.10.18478
16.10.172,058
16.10.16385
16.10.152,055
16.10.1413
16.10.13356
16.10.121,645
16.10.1111
16.10.10129
16.10.912,785
16.10.8268
16.10.7205
16.10.62
16.10.51
16.10.43
16.10.31
16.10.237
16.10.16
16.10.06
16.9.036
16.8.215
16.8.11
16.8.0121
16.7.1349
16.7.1281
16.7.113
16.7.10553
16.7.932
16.7.82
16.7.76
16.7.68
16.7.5250
16.7.43,021
16.7.32
16.7.23
16.7.12
16.7.01
16.6.5162
16.6.411
16.6.3606
16.6.2694
16.6.12
16.6.0266
16.5.622
16.5.59
16.5.42
16.5.319
16.5.23
16.5.142
16.5.07
16.4.3309
16.4.210
16.4.1247
16.4.04
16.3.25444
16.3.244
16.3.232
16.3.226
16.3.213
16.3.202
16.3.1910
16.3.1818
16.3.173
16.3.1682
16.3.1554
16.3.14247
16.3.1323
16.3.122
16.3.11177
16.3.102
16.3.95
16.3.8256
16.3.75
16.3.62
16.3.53
16.3.412
16.3.37
16.3.253
16.3.12
16.3.04
16.2.1222
16.2.05
16.2.0-03
16.1.335
16.1.298
16.1.14
16.1.0636
16.0.6181
16.0.5247
16.0.422
16.0.310
16.0.218
16.0.16
16.0.0668
15.3.41,363
15.3.36
15.3.24
15.3.110
15.3.039
15.2.624
15.2.52
15.2.43
15.2.33
15.2.23
15.2.163
15.2.06
15.1.03
15.0.528
15.0.46
15.0.34
15.0.213
15.0.111
15.0.017
14.1.1150
14.1.04
14.0.255
14.0.18,952
14.0.010
13.1.5639
13.1.42
13.1.39
13.1.210
13.1.121
13.1.04
13.0.420
13.0.352
13.0.23
13.0.13
13.0.05
12.5.124,284
12.5.11239
12.5.1011
12.5.9113
12.5.893
12.5.751
12.5.62
12.5.5117
12.5.4454
12.5.3417
12.5.2178
12.5.13
12.5.0159
12.4.0130
12.3.19
12.3.064
12.2.2-11
12.2.2-01
12.2.1136
12.2.013
12.1.1-02
12.1.0233
12.1.0-12
12.1.0-01
12.0.549
12.0.5-11
12.0.5-02
12.0.4-01
12.0.3221
12.0.2328
12.0.12
12.0.039
11.8.59,313
11.8.426
11.8.32,444
11.8.2362
11.8.122
11.8.02
11.7.1165
11.7.07
11.6.0256
12.0.0-015
11.5.1345
11.5.123
11.5.115
11.5.1017
11.5.921
11.5.82
11.5.77
11.5.63
11.5.53
11.5.410
11.5.35
11.5.21
11.5.1128
11.5.016
11.4.1265
11.4.02
11.3.091
11.2.325
11.2.28
11.2.13
11.2.014
11.1.114
11.1.1020
11.1.92,387
11.1.832
11.1.73
11.1.62
11.1.512
11.1.445
11.1.326
11.1.22
11.1.161
11.1.04
11.0.222
11.0.11
11.0.05
10.3.1449
10.3.03
10.2.5157
10.2.42
10.2.357
10.2.216
10.2.149
10.2.05
10.1.120
10.1.07
10.0.055
9.2.42,429
9.2.325
9.2.3-alpha.03
9.2.211
9.2.12
9.2.02
9.1.213
9.1.12
9.1.093
9.0.45
9.0.379
9.0.215
9.0.185
9.0.042
8.1.140
8.1.04
8.0.55
8.0.43
8.0.34
8.0.23
8.0.111
8.0.06
7.1.1688
8.0.0-alpha.11
7.1.012
7.0.5-alpha.11
7.0.44
7.0.4-alpha.22
7.0.4-alpha.12
7.0.335
7.0.3-alpha.11
7.0.238
7.0.1284
7.0.02
6.0.11,637
6.0.023
5.0.0456
5.0.0-alpha.22
5.0.0-alpha.11
4.1.22,501
4.1.138
4.1.031
4.0.624
4.0.533
4.0.4311
4.0.3929
4.0.263
4.0.2-alpha.11
4.0.1327
4.0.04
3.2.21,403
3.2.1116
3.2.011
3.1.26365
3.1.25247
3.1.2469
3.1.23214
3.1.2222
3.1.21116
3.1.204,775
3.1.191
3.1.1811
3.1.174
3.1.164
3.1.154
3.1.143
3.1.137
3.1.1223
3.1.1117
3.1.1010
3.1.954
3.1.812
3.1.78
3.1.63
3.1.53
3.1.493
3.1.310
3.1.24
3.1.18
3.1.07
3.0.121
3.0.113
3.0.103
3.0.93
3.0.87
3.0.70
3.0.61
3.0.51
3.0.42
3.0.37
3.0.27
3.0.15
3.0.05
2.15.02,108
2.14.315
2.14.2306
3.0.0-alpha.30
2.14.1154
3.0.0-alpha27
3.0.0-alpha10
2.14.0168
2.13.0249
2.12.1202
2.12.00
2.11.311
2.11.27
2.11.16
2.11.01
2.10.53
2.10.441
2.10.332
2.10.223
2.10.11
2.10.00
2.8.104
2.8.975
2.8.811
2.8.71
2.8.68
2.8.53
2.8.40
2.8.30
2.8.21
2.8.10
2.8.011
2.7.21
2.7.15
2.7.06
2.6.84
2.6.75
2.6.60
2.6.595
2.6.49
2.6.32
2.6.21
2.6.12
2.6.00
2.5.89
2.5.71
2.5.62
2.5.50
2.5.4-spawnglobal0
2.5.4177
2.5.3-spawnglobal1
2.5.31
2.5.20
2.5.10
2.5.09
2.4.20
2.4.10
2.4.00
2.3.42
2.3.30
2.3.20
2.3.10
2.3.00
2.2.40
2.2.32
2.2.20
2.2.11
2.2.00
2.1.30
2.1.20
2.1.10
2.1.00
2.0.41
2.0.30
2.0.20
2.0.10
2.0.01
2.0.0-alpha.170
2.0.0-alpha.161
2.0.0-alpha.150
2.0.0-alpha.140
2.0.0-alpha.130
2.0.0-alpha.120
2.0.0-alpha.110
2.0.0-alpha.101
2.0.0-alpha.90
2.0.0-alpha.80
2.0.0-alpha.70
2.0.0-alpha61
2.0.0-alpha50
2.0.0-alpha41
2.0.0-alpha31
2.0.0-alpha20
2.0.0-alpha10
1.5.1119
1.5.02
1.3.02
1.2.03
1.1.12
1.1.02
1.0.12
1.0.04