npm-check: Check for outdated, incorrect, and unused dependencies

Datetime:2016-08-23 02:46:24         Topic: Grunt          Share        Original >>
Here to See The Original Article!!!


Check for outdated, incorrect, and unused dependencies.


  • Tells you what's out of date.
  • Provides a link to the package's documentation so you can decide if you want the update.
  • Kindly informs you if a dependency is not being used in your code.
  • Works on your globally installed packages too, via -g .
  • Interactive Update for less typing and fewer typos, via -u .
  • Supports public and private @scoped/packages .
  • Supports ES6-style import from syntax.
  • Upgrades your modules using your installed version of npm, including the new npm@3 , so dependencies go where you expect them.
  • Works the public registry, private registries , andSinopia.
  • Avoids querying npm registries for packages with private: true in their package.json.
  • Emoji in a command-line app, because command-line apps can be fun too.

On the command line

This is how you should use npm-check .


$ npm install -g npm-check


$ npm-check

The result should look like the screenshot, or something nice when your packages are all up-to-date and in use.


  $ npm-check <path> <options>

  Where to check. Defaults to current directory. Use -g for checking global modules.

  -u, --update          Interactive update.
  -g, --global          Look at global modules.
  -s, --skip-unused     Skip check for unused packages.
  -p, --production      Skip devDependencies.
  -E, --save-exact      Save exact version (x.y.z) instead of caret (^x.y.z) in package.json.
  --no-color            Force or disable color output.
  --no-emoji            Remove emoji support. No emoji in default in CI environments.
  --debug               Debug output. Throw in a gist when creating issues on github.

  $ npm-check           # See what can be updated, what isn't being used.
  $ npm-check ../foo    # Check another path.
  $ npm-check -g -u     # Update globally installed modules by picking which ones to upgrade.

-u, --update

Show an interactive UI for choosing which modules to update.

Automatically updates versions referenced in the package.json .

Based on recommendations from the npm team, npm-check only updates using npm install , not npm update . To avoid using more than one version of npm in one directory, npm-check will automatically install updated modules using the version of npm installed globally.

-g, --global

Check the versions of your globally installed packages.

Tip: Use npm-check -u -g to do a safe interactive update of global modules, including npm itself.

-s, --skip-unused

By default npm-check will let you know if any of your modules are not being used by looking at require statements in your code.

This option will skip that check.

This is enabled by default when using global or update .

-p, --production

By default npm-check will look at packages listed as dependencies and devDependencies .

This option will let it ignore outdated and unused checks for packages listed as devDependencies .

-E, --save-exact

Install packages using --save-exact , meaning exact versions will be saved in package.json.

Applies to both dependencies and devDependencies .

--color, --no-color

Enable or disable color support.

By default npm-check uses colors if they are available.

--emoji, --no-emoji

Enable or disable emoji support. Useful for terminals that don't support them.


The API is here in case you want to wrap this with your CI toolset.

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


npmCheck(options) returns promise


global boolean

  • default is false

Use the globally installed packages. When true , the path is automatically set.

update boolean

  • default is false

Interactive update.

skipUnused boolean

  • default is false

Skip checking for unused packages.

ignoreDev boolean

  • default is false

Ignore devDependencies .

path string

  • default is cwd

Override where npm-check checks.

# saveExact boolean

  • default is false

Save exact versions to package.json


object of module names : data

data looks like this:

About the module

  • moduleName: name of the module.
  • homepage: url to the home page.


  • latest: latest according to the registry.
  • installed: version in node_modules.
  • packageJson: version or range in package.json.
  • devDependency: Is this a devDependency?
  • usedInScripts: Is this used in the scripts section of package.json?
  • mismatch: Is the version installed not match the range in package.json?
  • semverValidRange: Is the package.json range valid?
  • semverValid: Is the installed version valid semver?
  • easyUpgrade: Will using npm install upgrade the module?
  • bump: What kind of bump is required to get the latest, such as patch, minor, major.
  • unused: Is this module used in the code?


  • npm outdated - awkward output, requires --depth=0 to be grokable.
  • david - does not work with private registries.
  • update-notifier - for single modules, not everything in package.json.
  • depcheck - only part of the puzzle. npm-check uses depcheck.

About the Author

Hi! Thanks for checking out this project! My name is Dylan Greene . When not overwhelmed with my two young kids I enjoy contributing to the open source community. I'm also a tech lead at Opower .

Here's some of my other Node projects:

Name Description npm Downloads
grunt‑notify Automatic desktop notifications for Grunt errors and warnings. Supports OS X, Windows, Linux.
shortid Amazingly short non-sequential url-friendly unique id generator.
space‑hogs Discover surprisingly large directories from the command line
rss RSS feed generator. Add RSS feeds to any project. Supports enclosures and GeoRSS.
grunt‑prompt Interactive prompt for your Grunt config using console checkboxes, text input with filtering, password fields.
xml Fast and simple xml generator. Supports attributes, CDATA, etc. Includes tests and examples.
changelog Command line tool (and Node module) that generates a changelog in color output, markdown, or json for modules in's registry as well as any public repo.
grunt‑attention Display attention-grabbing messages in the terminal
observatory Beautiful UI for showing tasks running on the command line.
anthology Module information and stats for any @npmjs user
grunt‑cat Echo a file to the terminal. Works with text, figlets, ascii art, and full-color ansi.

This list was generated usinganthology.


Copyright (c) 2016 Dylan Greene, contributors.

Released under the MIT license .

Screenshots are CC BY-SA (Attribution-ShareAlike).

Generated usinggrunt-readme with grunt-templates-dylang on Tuesday, March 29, 2016. _To make changes to this document look in /templates/readme/


Put your ads here, just $200 per month.