Filtering Packages
npm-check-updates
provides powerful options to include or exclude specific packages from the update check.
Including Packages
You can specify which packages to check using the --filter
(or -f
) option, or by listing them as command-line arguments. This supports strings, wildcards, globs, comma-or-space-delimited lists, and regular expressions.
By Name
To upgrade only specific packages, list their names.
# Upgrade only mocha
ncu mocha
# Or using the filter option
ncu --filter mocha
# Upgrade only chalk, mocha, and react
ncu chalk mocha react
ncu --filter "chalk mocha react"
With Wildcards or Regex
Use wildcards or regular expressions for pattern-based filtering.
# Upgrade packages that start with "react-"
ncu react-*
# Using a regex
ncu "/^react-.*$/"
Note: Filters apply to the full package name, including the scope. For example,
ncu -f '*vite*'
will match@vitejs/plugin-react
.
Excluding Packages
To exclude packages, use the --reject
(or -x
) option, or prefix a filter with !
. This also supports strings, wildcards, globs, lists, and regex.
By Name
# Upgrade everything except nodemon
ncu --reject nodemon
# Using the alias
ncu -x nodemon
# Using a negated filter
ncu \!nodemon
Note on Shells: You may need to escape
!
(e.g.,\!nodemon
) in some shell environments to prevent it from being interpreted as a shell command.
With Wildcards or Regex
# Upgrade packages that do not start with "react-".
ncu \!react-*
# Using a regex (mac/linux)
ncu '/^(?!react-).*$/'
# Using a regex (windows)
ncu "/^(?!react-).*$/"
For more advanced filtering capabilities, see the CLI Reference for filter, filterResults, and filterVersion.