关于npm audit fix, npm install提醒漏洞


执行npm install 出现如下提醒

added 253 packages from 162 contributors and audited 1117 packages in 42.157s
found 5 vulnerabilities (1 low, 4 high)
  run `npm audit fix` to fix them, or `npm audit` for details html



按照控制台提示的命令,输入‘npm audit fix’后,控制台提示:

package update for 5 vulns involved breaking changes
  (use `npm audit fix --force` to install breaking changes; or do it by hand)


输入:‘npm audit fix --force’后,控制台提示:

added 199 packages from 111 contributors, removed 64 packages and updated 23 packages in 42.194sfixed 5 of 5 vulnerabilities in 1117 scanned packages
  1 package update for 5 vulns involved breaking changes
  (installed due to `--force` option)



重新输入‘npm audit’:

                  === npm audit security report ===

found 0 vulnerabilities
 in 4598 scanned packages



终于一切正常。

出于好奇,从npm官网上查阅了对于npm audit fix的相关介绍。

npm audit : npm@5.10.0 & npm@6,允许开发人员分析复杂的代码,并查明特定的漏洞和缺陷。

npm audit fix :npm@6.1.0, 检测项目依赖中的漏洞并自动安装需要更新的有漏洞的依赖,而不必再自己进行跟踪和修复。

同时,官网中还提供了一些其他的命令,整理如下:

1.运行audit fix,但是只更新pkglock, 不更新node_modules:

$ npm audit fix --package-lock-only
2. 只更新dependencies中安装的包,跳过devDependencies中的包:

$ npm audit fix --only=prod
3.运行命令,得到audit fix将会更新的内容,并且输出json格式的安装信息,但是并不真的安装更新:

$ npm audit fix --dry-run --json
4. 得到json格式的详细检测报告

$ npm audit --json
附:npm-audit 官网地址:https://docs.npmjs.com/cli/audit


尊重作者劳动成果:https://blog.csdn.net/zhuralll112/article/details/85934151

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值