npm audit fix

執行npm install 出現以下提醒html

 
  1. added 253 packages from 162 contributors and audited 1117 packages in 42.157sjava

  2. found 5 vulnerabilities (1 low, 4 high)node

  3. run `npm audit fix` to fix them, or `npm audit` for details htmlsql

按照控制檯提示的命令,輸入‘npm audit fix’後,控制檯提示:npm

 

 
  1. 1 package update for 5 vulns involved breaking changesjson

  2. (use `npm audit fix --force` to install breaking changes; or do it by hand)spa

輸入:‘npm audit fix --force’後,控制檯提示:code

 
  1. added 199 packages from 111 contributors, removed 64 packages and updated 23 packages in 42.194sfixed 5 of 5 vulnerabilities in 1117 scanned packageshtm

  2. 1 package update for 5 vulns involved breaking changesci

  3. (installed due to `--force` option)

從新輸入‘npm audit’:

 

 
  1. === npm audit security report ===

  2.  
  3. found 0 vulnerabilities

  4. 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
相關文章
相關標籤/搜索