NPM.Duplicate (NPM v0.6.0)

Copy Markdown View Source

Finds packages installed at multiple versions in the dependency tree.

Duplicates inflate node_modules size and can cause subtle bugs when multiple copies of a library coexist.

Summary

Functions

Counts total duplicate packages.

Scans the lockfile for packages present at different versions.

Formats duplicate report for display.

Returns the potential disk savings if duplicates were deduped.

Functions

count(lockfile)

@spec count(map()) :: non_neg_integer()

Counts total duplicate packages.

find(lockfile)

@spec find(map()) :: [%{name: String.t(), versions: [String.t()]}]

Scans the lockfile for packages present at different versions.

format_report(dupes)

@spec format_report([%{name: String.t(), versions: [String.t()]}]) :: String.t()

Formats duplicate report for display.

potential_savings(dupes)

@spec potential_savings([%{name: String.t(), versions: [String.t()]}]) ::
  non_neg_integer()

Returns the potential disk savings if duplicates were deduped.