我想在我的应用程序中使用react-highcharts
。我使用了npm install react-highcharts
,它成功地发出了警告:
found 1 high severity vulnerability, run `npm audit fix` to fix them, or `npm audit` for details.
npm audit fix
无反应;它说我必须手动修复这个问题。我运行npm audit
查看发生了什么,得到
=== npm audit security report ===
┌──────────────────────────────────────────────────────────────────────────────┐
│ Manual Review │
│ Some vulnerabilities require your attention to resolve │
│ │
│ Visit https://go.npm.me/audit-guide for additional guidance │
└──────────────────────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ High │ Cross-Site Scripting │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ highcharts │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in │ >=7.2.2 <8.0.0 || >=8.1.1 │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ react-highcharts │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path │ react-highcharts > highcharts │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info │ https://npmjs.com/advisories/1227 │
└───────────────┴──────────────────────────────────────────────────────────────┘
found 1 high severity vulnerability in 994 scanned packages
1 vulnerability requires manual review. See the full report for details.
"更多信息"链接和"修补;我们发现在highcharts>=8.1.1中修复了这个问题。最新的版本是highcharts@9.0.0
,所以我决定更新它:
❯ npm update highcharts -dd
npm info it worked if it ends with ok
npm verb cli [
npm verb cli '/usr/local/bin/node',
npm verb cli '/usr/local/bin/npm',
npm verb cli 'update',
npm verb cli 'highcharts',
npm verb cli '-dd'
npm verb cli ]
npm info using npm@6.14.10
npm info using node@v14.15.4
npm verb npm-session 0b92b8dc64938cea
npm verb update computing outdated modules to update
npm verb exit [ 0, true ]
npm timing npm Completed in 1507ms
npm info ok
"如果以ok结尾,"但是看:
❯ npm list highcharts
myproj@1.0.0 /Users/actinidia/myproj
└─┬ react-highcharts@16.1.0
└── highcharts@6.2.0
我还有highcharts@6.2.0
!运行npm install highcharts
只会导致highcharts的第二个副本,尽管新版本确实是9.0.0版本:
├── highcharts@9.0.0
└─┬ react-highcharts@16.1.0
└── highcharts@6.2.0
我如何更新react-highcharts
将使用的依赖?
您应该先卸载highcharts然后重新安装。
npm uninstall react-highcharts
npm install react-highcharts
我听从了ppotaczek的建议,为Highcharts安装了官方支持的包装器。就像
❯ npm install highcharts-react-official
npm WARN highcharts-react-official@3.0.0 requires a peer of highcharts@>=6.0.0
but none is installed. You must install peer dependencies yourself.
+ highcharts-react-official@3.0.0
added 1 package and audited 992 packages in 4.48s
❯ npm install highcharts
+ highcharts@9.0.0
added 1 package from 1 contributor and audited 993 packages in 4.978s
Remove installed:node_modules
andpackage-lock.json
修改package.json
格式如下
npm audit fix --force
npm install