同时使用React和Serve两个文件时,发现1个低严重性漏洞错误

时间:2020-05-13 19:52:50

标签: node.js reactjs npm

节点js给我以下错误。另外,当我使用ReactJs时,它分别渲染App.jsindex.js文件。这意味着每个功能执行两次。我怀疑此错误也应归咎于此。你们中的任何一个可以帮助我解决问题。


   === npm audit security report ===                        


                                       Manual

   Review                                  
               Some vulnerabilities require your attention to resolve             

                Visit https://go.npm.me/audit-guide for additional guidance           


        Low             Prototype Pollution                                           

        Package         yargs-parser                                                  

        Patched in      >=13.1.2 <14.0.0 || >=15.0.1 <16.0.0 || >=18.1.2              

        Dependency of   react-scripts                                                 

        Path            react-scripts > webpack-dev-server > yargs > yargs-parser     

        More info       https://npmjs.com/advisories/1500                             

      found 1 low severity vulnerability in 1668 scanned packages
        1 vulnerability requires manual review. See the full report for details.

2 个答案:

答案 0 :(得分:1)

这只是项目依赖关系中潜在漏洞的审核报告,与实际项目代码无关。

要解决此问题,请运行以下命令:

  • npm audit fix
  • npm update

更新:似乎该问题尚未在库的发行版本中得到解决。此外,没有已知的here缓解步骤。但是,发布修补程序后,上述步骤将起作用

答案 1 :(得分:-1)

我在这里找到了一些策略。当我将类组件用于app.js文件时,就会出现此状态。但是,当我使用功能组件时,却没有发生。

这是两次渲染。 ?

import React, {Component} from 'react'

export default class App extends Component {
    render() {
        return(
            <div>
                { console.log('f')}
            </div>)
    }
}

这不会两次呈现?

import React from 'react';

function App() {
  return (
        <div >
            {console.log("d")}
        </div>
  )
}

export default App