20

在我的项目中每次安装新的 NPM 模块后,我都会收到以下错误:

[!] 40 vulnerabilities found - Packages audited: 5840 (0 dev, 299 optional)
    Severity: 8 Low | 24 Moderate | 8 High

然后我运行npm audit并获得了 40 个漏洞的详细信息,例如:

# Run  npm install npm@6.0.1  to resolve 22 vulnerabilities
SEMVER WARNING: Recommended action is a potentially breaking change
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ Moderate      │ Prototype pollution                                          │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ hoek                                                         │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ npm                                                          │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ npm > libcipm > npm-lifecycle > node-gyp > request > hawk >  │
│               │ boom > hoek                                                  │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://nodesecurity.io/advisories/566                       │
└───────────────┴──────────────────────────────────────────────────────────────┘

或这个 :

# Run  npm update fsevents --depth 2  to resolve 3 vulnerabilities
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ Low           │ Regular Expression Denial of Service                         │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ debug                                                        │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ chokidar                                                     │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ chokidar > fsevents > node-pre-gyp > tar-pack > debug        │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://nodesecurity.io/advisories/534                       │
└───────────────┴──────────────────────────────────────────────────────────────┘

所以我运行npm install npm@6.0.1(即使我已经有 6.0.1)然后npm update fsevents --depth 2但之后我重新运行npm audit并且没有任何改变,我仍然有相同的 40 个漏洞,其中一些非常可怕。我该怎么办 ?

4

4 回答 4

6

这在 MacOS 上对我有用:

  • 将 NPM 更新到新的 6.1.0。它引入了一个“npm audit fix”命令,更多信息在这里
  • 运行“npm 审计修复”。

当您再次运行“npm audit”时,剩下的唯一漏洞应该是“手动审查”问题。

于 2018-05-25T11:25:28.927 回答
2

这似乎是 npm 6.0.1 中与处理可选依赖项相关的错误:https ://github.com/npm/npm/issues/20577

于 2018-05-14T20:07:21.687 回答
2

这对我有用:

Do the npm audit suggestions that aren't npm updates
Delete package-lock.json
Delete the node_modules folder
Run npm install again

https://github.com/npm/npm/issues/20684

于 2020-03-12T18:20:54.417 回答
0

来源:https ://github.com/npm/npm/issues/20675 。一个fsevents问题可能与以下事实有关

fsevents不能安装在windows上,所以你必须在macOS机器上更新它。

这有点奇怪,因为查看 exhnozoaa 的解决方案,截至此日期似乎暗示并非如此:

我可以通过以下步骤在 Windows 上解决此问题。

  1. package-lock.json在编辑器中打开。
  2. 搜索"fsevents"。找到直接在 下的对象"dependencies"
  3. 删除"fsevents"(键和整个对象)。
  4. 从终端运行npm install.

这应该使用与其他软件包兼容的最新版本重新生成该部分。我真的不认为这是修复它的好方法,但它对我有用。

于 2018-05-20T14:20:31.090 回答