npm why (who installs this package)
v1.0.0Why 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:),…
| Parameter | Type | Description |
|---|---|---|
lockfile | object | string | Or: the content of package-lock.json (object or JSON text), lockfileVersion 2 or 3. |
lockfile_path | string | Path 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_paths | integer | Chains to show per copy, shortest first (default 5). |
package | string | Package name, e.g. "debug" or "@babel/core". |
package_json | object | string | Optional: the root package.json (object or JSON text), used for "overrides". Read automatically with lockfile_path. |
packages | array | Or several package names at once. |
version | string | Optional 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.
| Parameter | Type | Description |
|---|---|---|
limit | integer | Maximum packages to list, worst first (default 30). |
lockfile | object | string | Or: the content of package-lock.json (object or JSON text), lockfileVersion 2 or 3. |
lockfile_path | string | Path 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_json | object | string | Optional: the root package.json (object or JSON text), used for "overrides". Read automatically with lockfile_path. |