NPM: Why is this package installed?

How do I determine why a particular package is installed? In other words, what package(s) depend on this package?

The package in question is babelify. npm ls shows it at the top level, but it is not included in package.json anywhere.


Use npm ls to list installed packages and see the dependency graph of a given package eg:

> npm ls core-js

my_module /path/to/my_module>
└─┬ [email protected]
  └─┬ [email protected]
    └─┬ [email protected]
      └─┬ [email protected]
        └─┬ [email protected]
          └── [email protected]

As you mention, npm ls shows packages and their dependencies:

> npm ls leveldown
[email protected] C:\Users\mikem\Code\appless
`-- @architect/[email protected]
  `-- [email protected]
    `-- UNMET OPTIONAL DEPENDENCY [email protected]

If npm ls shows it at the top level, and it is not a dependency in the top level package.json, it's likely was previously required and is now no longer used.

Use npm prune to remove the unused package.