美文网首页
2020-09-21 npm系列相关操作学习

2020-09-21 npm系列相关操作学习

作者: 前端丶凯 | 来源:发表于2020-09-21 10:10 被阅读0次

1.npm audit fix

背景:

执行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’后,控制台提示:

1 packageupdatefor5vulns involved breaking changes  (use`npm audit fix --force`toinstallbreaking changes; ordoitbyhand)

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

added199packagesfrom111contributors,removed64packagesandupdated23packagesin42.194sfixed5of5vulnerabilitiesin1117 scannedpackages1packageupdatefor5vulnsinvolvedbreakingchanges(installeddueto`--force`option)

重新输入‘npm audit’:

===npmauditsecurityreport===found0vulnerabilitiesin4598 scannedpackages

终于一切正常。

出于好奇,从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

相关文章

  • 2020-09-21 npm系列相关操作学习

    1.npm audit fix 背景: 执行npm install 出现如下提醒 added 253 packag...

  • npm相关操作

    操作环境: windows10 ,NodeJS v8.3.0,NPM v5.3.0 1.查看基本配置 2.查看完整...

  • npm相关操作

    1.npm install -g npm 更新到最新版本 2.http://www.voidcn.com/arti...

  • 实现npm仓库自动登录

    该脚本主要基于shelljs实现npm自动登录功能,执行npm login相关操作

  • npm 相关

    1.新装第三方库 :npm install 库名 --save 2.复制或下载项目:npm install 3.安...

  • npm相关

    收集一些window下npm相关的资料。 1.npm未能加载Visual C++组件,解决办法win10 错误提示...

  • npm相关

    Vue:1,使用Vue需要用到脚手架 vue-li,安装的时候用webpack-simple安装脚手架2,使用之...

  • NPM相关

    npm 官网镜像国内访问太慢,这里我使用了淘宝的npm镜像,安装方法如下: 执行后我们就可以使用 cnpm 命令来...

  • npm相关

    1、npm安装模块 【npm install xxx】利用 npm 安装xxx模块到当前命令行所在目录;【npm ...

  • npm相关

网友评论

      本文标题:2020-09-21 npm系列相关操作学习

      本文链接:https://www.haomeiwen.com/subject/wnzmyktx.html