NPM.Prune (NPM v0.6.0)

Copy Markdown View Source

Identifies and removes extraneous packages from node_modules.

Compares the installed packages against the lockfile to find packages that are no longer needed.

Summary

Functions

Performs a dry run, returning what would be removed.

Calculates the total disk size of extraneous packages.

Finds extraneous packages in node_modules that aren't in the lockfile.

Removes extraneous packages from node_modules. Returns the list of removed entries.

Types

prune_entry()

@type prune_entry() :: %{
  name: String.t(),
  version: String.t() | nil,
  path: String.t(),
  reason: :not_in_lockfile | :orphaned_scope
}

Functions

dry_run(node_modules_dir, lockfile)

@spec dry_run(String.t(), map()) :: %{
  to_remove: [prune_entry()],
  count: non_neg_integer()
}

Performs a dry run, returning what would be removed.

extraneous_size(entries)

@spec extraneous_size([prune_entry()]) :: non_neg_integer()

Calculates the total disk size of extraneous packages.

find_extraneous(node_modules_dir, lockfile)

@spec find_extraneous(String.t(), map()) :: [prune_entry()]

Finds extraneous packages in node_modules that aren't in the lockfile.

prune!(node_modules_dir, lockfile)

@spec prune!(String.t(), map()) :: [prune_entry()]

Removes extraneous packages from node_modules. Returns the list of removed entries.