Skip to content

Instantly share code, notes, and snippets.

@glenjamin
Created March 2, 2015 22:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glenjamin/aaf9103b9caa6204cf48 to your computer and use it in GitHub Desktop.
Save glenjamin/aaf9103b9caa6204cf48 to your computer and use it in GitHub Desktop.
What modules am I using?
# Run the following in a directory containing npm projects
# list all modules being used directly (no sub-dependencies)
ls */package.json | xargs -n1 dirname | \
xargs -n1 -I {} bash -c 'cd {} && npm ls --depth=0 2>/dev/null | grep -oiE " [A-Z0-9\-]+@"' | \
cut -d @ -f 1 | sort -u
# list all modules being used directly and which project uses them
ls */package.json | xargs -n1 dirname | \
xargs -n1 -I {} bash -c 'cd {} && npm ls --depth=0 2>/dev/null | grep -oiE " [A-Z0-9\-]+@" | sed "s/\$/ in {}/"' | \
sort
# list all versions of all modules being used directly & which project uses them
ls */package.json | xargs -n1 dirname | \
xargs -n1 -I {} bash -c 'cd {} && npm ls --depth=0 2>/dev/null | grep -oiE " [A-Z0-9\-]+@\S+" | sed "s/\$/ in {}/"' | \
sort
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment