Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
npm-check-updates
Advanced tools
Find newer versions of dependencies than what your package.json allows
npm-check-updates is a command-line tool that allows you to find and update outdated npm dependencies in your project. It helps you keep your project dependencies up-to-date by checking for newer versions and updating your package.json file accordingly.
Check for outdated dependencies
This command checks for any outdated dependencies in your project and lists them along with the latest versions available.
ncu
Update package.json with latest versions
This command updates your package.json file with the latest versions of all dependencies.
ncu -u
Interactive mode
This command runs npm-check-updates in interactive mode, allowing you to selectively choose which dependencies to update.
ncu -i
Filter dependencies
This command filters the dependencies to check for updates only within a specific scope or matching a specific pattern.
ncu '/^@my-scope/'
Upgrade specific dependencies
This command checks for updates and upgrades only the specified dependency (e.g., lodash).
ncu lodash
npm-check is another tool for checking and updating outdated npm dependencies. It provides a more interactive experience compared to npm-check-updates, allowing you to see which dependencies are outdated, unused, or missing, and to update them interactively.
depcheck is a tool that helps you find unused dependencies in your project. While it doesn't focus on updating dependencies, it complements npm-check-updates by identifying dependencies that are no longer needed.
npm-check-updates is a command-line tool that allows you to find and save the latest versions of dependencies, regardless of any version constraints in your package.json file (unlike npm itself).
npm-check-updates maintains your existing semantic versioning policies, i.e., it will upgrade your "express": "^4.11.2"
dependency to "express": "^5.0.0"
when express 5.0.0 is released.
npm install -g npm-check-updates
Show any new dependencies for the project in the current directory:
$ ncu
express 4.12.x → 4.13.x
multer ^0.1.8 → ^1.0.1
react-bootstrap ^0.22.6 → ^0.24.0
react-a11y ^0.1.1 → ^0.2.6
webpack ~1.9.10 → ~1.10.5
Run with -u to upgrade your package.json
Upgrade a project's package.json:
Make sure your package.json is in version control and all changes have been committed. This will overwrite your package.json.
$ ncu -u
express 4.12.x → 4.13.x
package.json upgraded
Include or exclude specific packages:
# match mocha and should packages exactly
$ ncu mocha,should
# match packages that start with "gulp-" using regex
$ ncu /^gulp-/
# match packages that do not start with "gulp-". Note: single quotes are required
# here to avoid inadvertant bash parsing
$ ncu '/^(?!gulp-).*$/'
-d, --dev check only devDependencies
-e, --error-level 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)
-g, --global check global packages instead of in the current project
-h, --help output usage information
-j, --jsonAll output new package.json instead of human-readable
message
--jsonUpgraded output upgraded dependencies in json
--packageData include stringified package.json (use stdin instead)
--packageFile package.json location (default: ./package.json)
-o, --optional check only optionalDependencies
-p, --prod check only dependencies (not devDependencies)
-r, --registry specify third-party NPM registry
-s, --silent don't output anything
-t, --greatest find the highest versions available instead of the
latest stable versions (alpha release only)
-u, --upgrade upgrade package.json dependencies to match latest
versions (maintaining existing policy)
-ua, --upgradeAll upgrade package.json dependencies even when the latest
version satisfies the declared semver dependency
-V, --version output the version number
The tool allows integration with 3rd party code:
var ncu = require('npm-check-updates');
ncu.run({
packageData: fs.readFileSync('./some/project/package.json', 'utf-8'),
// Any command-line option can be specified here.
// These are set by default:
// silent: true,
// jsonUpgraded: true
}).then(function(upgraded) {
console.log('dependencies to upgrade:', upgraded);
});
npm-check-updates v2 has a few important differences from v1:
1.0.0
to 1.1.0
). This change was made because npm update
handles upgrades within the satisfied range just fine, and npm-check-updates is primarily intended to provide functionality not otherwise provided by npm itself. These satisfied dependencies will still be shown when you run npm-check-updates, albeit with a short explanation. For the old behavior, add the -ua/--upgradeAll option.ncu /^gulp-/
). For the old behavior (specifying an alternative package.json), pipe the package.json through stdin.ncu
instead of npm-check-updates
. npm-check-updates
is preserved for backwards-compatibility.ncu --packageFile package.json
.Please file an issue on github! Contributors are responsive and happy to assist.
Always include your package.json when reporting a bug!
Pull requests are welcome, and will not collect dust :)
FAQs
Find newer versions of dependencies than what your package.json allows
The npm package npm-check-updates receives a total of 321,221 weekly downloads. As such, npm-check-updates popularity was classified as popular.
We found that npm-check-updates demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.