我在 1 个月前使用 create-react-app 创建了一个新应用,最近我收到了来自 npm update
的消息:
80 moderate severity vulnerabilities
To address issues that do not require attention, run:
npm audit fix
To address all issues (including breaking changes), run:
npm audit fix --force
npm audit
给我:
postcss 7.0.0 - 8.2.9
Severity: moderate
Regular Expression Denial of Service - https://npmjs.com/advisories/1693
fix available via `npm audit fix --force`
Will install react-scripts@2.1.8, which is a breaking change
我尝试了 npm audit fix
,但没有任何变化,npm audit fix --force
安装了旧版本的 react-script(当前为 4.0.3 到 2.1.8),因此它似乎不是一个好的解决方案。>
npm install postcss@latest --save
和 npm install postcss@8.2.15 --save
也不会改变任何东西。
修复此漏洞的最佳方法是什么?
答案 0 :(得分:2)
此问题已在此处得到解答:https://stackoverflow.com/a/67502823/8499653
对 postcss 8 的支持已经合并,可能很快就会发布
您可以使用 npm 包 npm-force-resolutions
临时修复此问题
答案 1 :(得分:0)
我为此浪费了半天时间,所有基于 NPM 的解决方案和软件包都不起作用。 force-resolutions 对我不起作用。
切换到 Yarn
使这变得更简单。
rm -rf ./node_modules
rm ./package-lock.json
编辑您的package.json
:
在此处也添加要从 npm / yarn audit
升级的任何其他软件包版本
"resolutions":
{
"postcss": "^8.2.10"
},
yarn install
然后运行 yarn audit
应该会产生魔法词:
0 vulnerabilities found - Packages audited: 999
✨ Done in 1.10s.