简体   繁体   English

`npm install`和`npm audit`之间的区别是什么?

[英]Difference between `npm install` and `npm audit` counts?

After the recent addition of npm audit (for auditing dependencies) I noticed a huge discrepancy between how many packages are added (installed in node_modules ) and how many are audited by npm . 最近加入后npm audit (审计依赖)我注意到之间的包裹数量巨大的差异added (安装在node_modules ),多少audited通过npm Here's an example: 这是一个例子:

npm安装输出

Here are my questions: 这是我的问题:

  • Am I correct that 281 is the total number of packages installed? 我是否更正, 281是安装的软件包总数?
  • Why is npm auditing so many more packages than the ones in my project? 为什么npm审核的包比我项目中的包多得多?

It makes sense to me that npm might have to go back out and audit other package versions if it finds a vulnerability, but in this case it found 0 vulnerabilities so why the additional work? 对我来说,如果发现漏洞, npm可能不得不退出并audit其他软件包版本,但是在这种情况下,它found 0 vulnerabilities ,为什么要进行额外的工作呢?

UPDATE: 更新:

I think there's a little confusion about top-level vs sub dependencies. 我认为顶级vs子依赖关系有点混乱。 Run the following commands to reproduce a similar discrepancy: 运行以下命令以重现类似的差异:

mkdir test-npm-count-discrepancy
cd test-npm-count-discrepancy
npm init
npm i standard-version

Notice that (at the time of writing this) 200+ dependencies are added (ie standard-version and all its sub dependencies) but 1000+ packages are audited . 请注意(在撰写本文时) added 200+依赖项(即standard-version及其所有子依赖项),但audited 1000+包。 Just to re-iterate, the main question from above is "why is npm auditing more packages than what's actually installed?". 只是为了重新迭代,上面的主要问题是“为什么npm审计的包比实际安装的更多?”。

For the first question: - the community, without a link to something like a dependency list or your package.json, wouldn't really be able to say so. 对于第一个问题: - 社区,没有链接到依赖列表或package.json之类的东西,实际上不能这么说。 However, if in your package file only has a few, then it still is normal most of the time. 但是,如果在您的包文件中只有少数几个,那么大部分时间它仍然是正常的。 You may have installed 12 yourself, but NPM auto-installs most, if not all, dependencies for your app's dependencies for you. 您可能已经自己安装了12个,但是NPM会为您的应用程序的依赖项自动安装大多数(如果不是全部)依赖项。 It helps things speed up your workflow. 它可以帮助您加快工作流程。

For the second question: - as mentioned in my response to the first question, it is auditing both the ones you installed and the ones that were installed automatically so that the ones you installed work properly. 对于第二个问题: - 正如我对第一个问题的回答中所提到的,它是审核您安装的和自动安装的那些,以便您安装的那些正常工作。

For the third question: - It always checks for vulnerabilities marked by developers so you can have the latest version which is, most of the time, the least buggy, the most functional, and most secure. 对于第三个问题: - 它总是检查由开发人员标记的漏洞,以便您可以拥有最新版本,大多数情况下,最少的错误,最实用,最安全。

Edit: The whole point of npm install is to update current dependencies and install new ones to the directory. 编辑: npm install是更新当前依赖项并在目录中安装新的依赖项。 The point of npm audit is to check for dependencies that have updates marked to fix security issues. npm audit的要点是检查是否有标记为更新安全问题的更新的依赖项。

Edit 2: I think I've got it: it could be auditing the installed dependencies for production, your dependencies, and the dev-dependencies to warn you that one of your dependencies was built insecurely by the developer. 编辑2:我认为我已经得到了它:它可能是审计生产的依赖关系,你的依赖关系和dev依赖关系,以警告你,你的一个依赖项是由开发人员不安全地构建的。

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

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