当我们升级 package.json 包后,容易出现下面的错误:
npm WARN babel-eslint@10.1.0 requires a peer of eslint@>= 4.12.1 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-config-react-app@5.2.1 requires a peer of @typescript-eslint/eslint-plugin@2.x but none is installed. You must install peer dependencies yourself.
npm WARN eslint-config-react-app@5.2.1 requires a peer of @typescript-eslint/parser@2.x but none is installed. You must install peer dependencies yourself.
npm WARN eslint-config-react-app@5.2.1 requires a peer of eslint@6.x but none is installed. You must install peer dependencies yourself.
npm WARN eslint-config-react-app@5.2.1 requires a peer of eslint-plugin-react@7.x but none is installed. You must install peer dependencies yourself.
npm WARN eslint-loader@3.0.3 requires a peer of eslint@^5.0.0 || ^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-plugin-flowtype@4.6.0 requires a peer of eslint@>=6.1.0 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-plugin-import@2.20.1 requires a peer of eslint@2.x - 6.x but none is installed. You must install peer dependencies yourself.
npm WARN eslint-plugin-jsx-a11y@6.2.3 requires a peer of eslint@^3 || ^4 || ^5 || ^6 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-plugin-react-hooks@1.7.0 requires a peer of eslint@^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN rc-picker@1.10.7 requires a peer of dayjs@^1.8.18 but none is installed. You must install peer dependencies yourself.
audited 2211 packages in 7.724s
69 packages are looking for funding
run `npm fund` for details
found 4992 low severity vulnerabilities
run `npm audit fix` to fix them, or `npm audit` for details
问题分析
package-lock.json 中锁定的包版本和新的包依赖的版本有冲突,所以 npm 不知道如何处理这些冲突。
解决办法
rm package-lock.json && rm -rf node_modules/ && npm install
注意⚠️
任何版本升级都可能产生新的问题,建议充分测试后才能上线运行