简体   繁体   中英

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

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

➜  node-address-rfc2821 git:(master) npm ls
address-rfc2821@2.0.0 /Users/matt/git/node-address-rfc2821
├─┬ nearley@2.20.1
│ ├── commander@2.20.3
│ ├── moo@0.5.1
│ ├── railroad-diagrams@1.0.0
│ └─┬ randexp@0.4.6
│   ├── discontinuous-range@1.0.0
│   └── ret@0.1.15
└── punycode@2.1.1

The command npm ls has been around since at least 2011

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM