John Vandivier
John Vandivier

Reputation: 2426

Determine npm package dependency chain

I run npm install on a project and get a deprecation error for an underlying dependency.

It is not a direct dependency, it's in node_modules. How can I easily figure out which of my dependencies eventually depends on the problematic library?

A first-pass solution is to use grep, but 2 issues:

  1. This will help me locate the package.json containing the problematic dependency, but there could be 2, 3, 4...n packages between that and my own project's package.json
  2. grep is a bit slow

Upvotes: 1

Views: 1455

Answers (1)

Matt Simerson
Matt Simerson

Reputation: 1115

What's wrong with using npm ls? Here's sample output for a module:

➜  node-address-rfc2821 git:(master) npm ls
[email protected] /Users/matt/git/node-address-rfc2821
├─┬ [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ └─┬ [email protected]
│   ├── [email protected]
│   └── [email protected]
└── [email protected]

The command npm ls has been around since at least 2011

Upvotes: 1

Related Questions