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 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:
$ ncuexpress 4.12.x → 4.13.xmulter ^0.1.8 → ^1.0.1react-bootstrap ^0.22.6 → ^0.24.0react-a11y ^0.1.1 → ^0.2.6webpack ~1.9.10 → ~1.10.5Run 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 -uexpress 4.12.x → 4.13.xpackage.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 -h, --help output usage information -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 -j, --jsonAll output new package.json instead of human-readable message --jsonUpgraded output upgraded dependencies in json -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';ncurunpackageData: fsreadFileSync'./some/project/package.json' 'utf-8'// Any command-line option can be specified here.// These are set by default:// silent: true,// jsonUpgraded: truethenconsole.log'dependencies to upgrade:' upgraded;;
npm-check-updates v2 has a few important differences from v1:
1.1.0). This change was made because
npm updatehandles 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.
npm-check-updatesis preserved for backwards-compatibility.
Always include your package.json when reporting a bug!
Pull requests are welcome, and will not collect dust :)