Check dependencies in your node module
Keeping track of your dependencies is not an easy task, especially if you have a big application.
Are you sure you are using all of the dependencies you define in your
package.json file? One way to find out is to
look at all your files and check which modules you are using, but that's too time consuming. Or maybe you can do a
grep on all the files of your project, and then some
grep -v to remove the junk. But that's a hassle too.
And that is why
It's a nifty little tool that looks at your
package.json file and scans your code in order to find any unused
Using grunt ? Checkout the grunt plugin.
npm install depcheck -g
As easy as depcheck [DIRECTORY].
Where DIRECTORY is the root directory of your application (where the package.json is). This will list all the unused dependencies in your code if any.
--no-dev : by default
depcheck looks at
devDependencies, this flag will tell it not to look at "devDependencies".
--json : output results to JSON
Or, as a lib:
var path = require"path";var depcheck = require"depcheck";var options ="withoutDev": false // Check against devDependencies too"ignoreDirs": // Pathnames to ignore"sandbox""dist""bower_components""ignoreMatches": // Ignore dependencies that match these minimatch patterns"grunt-*";var root = pathresolve"some path";depcheckroot optionsconsole.logunuseddependencies;console.logunuseddevDependencies;console.logunusedinvalidFiles; // JS files that couldn't be parsed;
Well, it's more of a "What do you think guys?".
There are a couple of things I would like to do if anyone is interested:
depcheckcan't find in your code