如何在NPM中找到依赖于给定包的所有已安装软件包?

xdh*_*ore 85 node.js npm

我有一个我要更新的npm包.我可以更新我的package.json,但我不想破坏一些东西.有没有办法列出所有依赖它的已安装软件包?

Dim*_*bas 122

您正在寻找https://docs.npmjs.com/cli/ls

例如,要查看哪些包依赖于contextify您,可以运行:

npm ls contextify
app-name@0.0.1 /home/zorbash/some-project
??? d3@3.3.6
  ??? jsdom@0.5.7
    ??? contextify@0.1.15
Run Code Online (Sandbox Code Playgroud)

  • 如果我想在未安装后者的情况下查看哪些软件包依赖于"contextify",该怎么办? (28认同)

mat*_*tpr 20

You may also find npm explain <package-name> useful as it explains why that package is installed, what depends on it, etc.

e.g. to understand why we have node-sass installed...

$ npm explain node-sass
node-sass@4.14.1 dev
node_modules/node-sass
  node-sass@"^4.8.3" from gulp-sass@4.1.1
  node_modules/gulp-sass
    dev gulp-sass@"^4.1.1" from the root project
Run Code Online (Sandbox Code Playgroud)