NPM.PhantomDep (NPM v0.6.0)

Copy Markdown View Source

Detects phantom (undeclared) dependencies.

A phantom dependency is one that can be required in code but is not declared in package.json — it only works because another package depends on it and it gets hoisted.

Summary

Functions

Counts phantom dependencies.

Finds packages in node_modules that aren't declared in package.json.

Formats a report of phantom dependencies.

Checks if a specific package is a phantom dependency.

Functions

count(pkg_data, lockfile)

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

Counts phantom dependencies.

detect(pkg_data, lockfile)

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

Finds packages in node_modules that aren't declared in package.json.

format_report(phantoms)

@spec format_report([String.t()]) :: String.t()

Formats a report of phantom dependencies.

phantom?(name, pkg_data)

@spec phantom?(String.t(), map()) :: boolean()

Checks if a specific package is a phantom dependency.