我有一个React Native项目(0.61.4),使用yarn
作为其包管理器。
当我运行yarn audit
时,会报告大量漏洞:
18202 vulnerabilities found - Packages audited: 958823
Severity: 18202 High
✨ Done in 14.34s.
大多数都处于一些非常深的依赖路径中。例如:
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ high │ Prototype Pollution │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ lodash │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in │ >=4.17.12 │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ react-native │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path │ react-native > @react-native-community/cli > │
│ │ metro-react-native-babel-transformer > @babel/core > lodash │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info │ https://www.npmjs.com/advisories/1065 │
└───────────────┴──────────────────────────────────────────────────────────────┘
当我运行
npm audit
时,它首先报告:Neither npm-shrinkwrap.json nor package-lock.json found: Cannot audit a project without a lockfile
所以我运行:
npm i --package-lock-only
生成了一个package-lock.json
文件。检查该文件,看起来是正确的。
现在运行npm audit
,结果如下:
=== npm audit security report ===
found 0 vulnerabilities
我不明白这两个包管理器之间的差异。为什么npm
报告0个错误,而yarn
报告18.202个错误?