Skip to content
npm dependencies graph metrics
JavaScript HTML Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
data
export
lib
online
sample
utils
.gitignore
01_get_graph.sh
LICENSE
README.md
checkDuplicates.js
collect.js
computeStats.js
convertToGraph.js
countAuthorDeps.js
countTotalDeps.js
countVersions.js
downloadStream.js
dump.js
make_snapshot.sh
package-lock.json
package.json
recommend.js
saveStats.js
soundsLike.js
what.common.js

README.md

npmrank

This repository computes various graph metrics for npm dependencies.

setup

git clone https://github.com/anvaka/npmrank.git
cd npmrank
npm install

Download the npm graph from npm:

./01_get_graph.sh

This will download graph from skimdb and save it to data folder. As of September 2016 this data is about 500MB. Convert it to ngraph.graph format for further analysis:

node --max-old-space-size=4096 convertToGraph.js

You are ready to analyze the graph.

Graph metrics: PageRank, HITS, and Node Degree

node --max-old-space-size=4096 computeStats.js ./data/dependenciesGraph.out.graph 100 > sample/dependencies.md
node --max-old-space-size=4096 computeStats.js ./data/devDependencies.out.graph 100 > sample/devdependencies.md
node --max-old-space-size=4096 computeStats.js ./data/allDependencies.out.graph 100 > sample/alldependencies.md

These commands analyze and print top 100 entries for the following metrics:

  • Indegree - most dependent upon packages. Demo
  • Outdegree - packages with highest number of dependencies. Demo
  • Pagerank - rough estimate of package importance, based on number of dependents/dependencies. Demo
  • Hubs and Authorities - alternative importance classification, also based on number of edges. Demo

Command line usage

The following line will compute number of unique packages, that depend on packages created and maintained by a given user (in this case it's @thlorenz):

node --max-old-space-size=4096 ./countAuthorDeps.js thlorenz

You can also count total dependents for a given search query. E.g. this will count number of packages that depend on either underscore or lodash:

node --max-old-space-size=4096 countTotalDeps.js "^(lodash|underscore)$"

NOTE: Total dependents means all transitive dependents as well (i.e. dependents of dependents, and so on).

To count which versions depend on your package you can use countVersions.js utility:

node --max-old-space-size=4096 countVersions.js jquery

To get list of packages grouped by version pass --print-names argument:

node --max-old-space-size=4096 countVersions.js ngraph.graph --print-names

To further narrow down this list and print only those deps that could receive a certain semver range, pass --semver argument. E.g.:

node --max-old-space-size=4096 countVersions.js lodash --semver='3.9.x'

Searching for packages that sounds like a given name

node --max-old-space-size=4096 soundsLike.js packageName [maxDistance=3]

Where

packageName [required] - name that you are investigating
maxDistance [optional, defaults to 2] - Levenshtein distance threshold. Smaller
 values yield better matches.

Examples:

# will find `digraph, mongraph, graph, egraph, ...`
node soundsLike.js ngraph

# this will narrow down results to edit distance 1
# `graph, egraph, ...`:
node soundsLike.js ngraph 1

Online

Discover relevant and popular packages quickly: http://anvaka.github.io/npmrank/online/ Select a keyword and get packages sorted by their pagerank value.

Daily metrics dump with all graphs is available here.

license

MIT

You can’t perform that action at this time.