简体   繁体   English

确定 npm 包依赖链

[英]Determine npm package dependency chain

I run npm install on a project and get a deprecation error for an underlying dependency.我在一个项目上运行npm install并收到一个底层依赖项的弃用错误。

It is not a direct dependency, it's in node_modules.它不是直接依赖,它在 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:第一次通过的解决方案是使用 grep,但有两个问题:

  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这将帮助我找到包含有问题的依赖项的 package.json,但在它和我自己项目的 package.json 之间可能有 2、3、4...n 个包
  2. grep is a bit slow grep 有点慢

What's wrong with using npm ls ?使用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命令npm ls至少从2011 年就已经存在

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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