npm why (who installs this package)

v1.0.0
io.github.Lawatch/npm-why Checked 3 days ago Published 19 days ago

Why a package is in node_modules, which versions, who pulls it in: npm explain from package-lock.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

why_npm_package Why is this npm package installed?

Answers "why is X in my node_modules, which version, and who pulls it in?" from package-lock.json, exactly like `npm explain X` but without node_modules: every installed copy of the package (version and folder), whether it is a direct dependency, dev-only or optional, the packages that require it with their version ranges, and the full chains from your package.json (your project › express@4.21.2 › debug@2.6.9). Give a version range (e.g. "<4.17.21") to find only the vulnerable copies after a security alert, and see which top-level dependency to upgrade. Handles workspaces, aliases (npm:),…

ParameterTypeDescription
lockfileobject | stringOr: the content of package-lock.json (object or JSON text), lockfileVersion 2 or 3.
lockfile_pathstringPath to package-lock.json / npm-shrinkwrap.json, or to the project folder (the package.json next to it is read too, for "overrides"). Easiest when the server runs on your machine.
max_pathsintegerChains to show per copy, shortest first (default 5).
packagestringPackage name, e.g. "debug" or "@babel/core".
package_jsonobject | stringOptional: the root package.json (object or JSON text), used for "overrides". Read automatically with lockfile_path.
packagesarrayOr several package names at once.
versionstringOptional semver range: only copies whose version matches (e.g. "<4.17.21" for a vulnerability, "^7").

npm_duplicates Which npm packages are installed in several versions?

Lists the packages that package-lock.json installs in more than one version (e.g. 4 versions of chalk), with how many copies, where, and which package asks for each version. Use it to shrink node_modules or a bundle, to understand "two copies of React" or "instanceof fails" bugs, and to know what `npm dedupe` or an upgrade could remove.

ParameterTypeDescription
limitintegerMaximum packages to list, worst first (default 30).
lockfileobject | stringOr: the content of package-lock.json (object or JSON text), lockfileVersion 2 or 3.
lockfile_pathstringPath to package-lock.json / npm-shrinkwrap.json, or to the project folder (the package.json next to it is read too, for "overrides"). Easiest when the server runs on your machine.
package_jsonobject | stringOptional: the root package.json (object or JSON text), used for "overrides". Read automatically with lockfile_path.