首页 > 解决方案 > ESLint 依赖失败

问题描述

我想在 VSCode 上的 React 项目中使用 ESLint,但它不起作用。当我进入

npm install

它向我展示了这一点:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! Found: type-fest@0.20.2
npm ERR! node_modules/type-fest
npm ERR!   type-fest@"^0.20.2" from globals@13.10.0
npm ERR!   node_modules/@eslint/eslintrc/node_modules/globals
npm ERR!     globals@"^13.9.0" from @eslint/eslintrc@0.4.3
npm ERR!     node_modules/@eslint/eslintrc
npm ERR!       @eslint/eslintrc@"^0.4.3" from eslint@7.32.0
npm ERR!       node_modules/eslint
npm ERR!         dev eslint@"^7.32.0" from the root project
npm ERR!         18 more (@typescript-eslint/eslint-plugin, ...)
npm ERR!   type-fest@"^0.20.2" from globals@13.10.0
npm ERR!   node_modules/eslint/node_modules/globals
npm ERR!     globals@"^13.6.0" from eslint@7.32.0
npm ERR!       dev eslint@"^7.32.0" from the root project
npm ERR!       18 more (@typescript-eslint/eslint-plugin, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peerOptional type-fest@"^0.13.1" from @pmmmwh/react-refresh-webpack-plugin@0.4.2
npm ERR! node_modules/@pmmmwh/react-refresh-webpack-plugin
npm ERR!   @pmmmwh/react-refresh-webpack-plugin@"0.4.2" from react-scripts@4.0.1
npm ERR!   node_modules/react-scripts
npm ERR!     react-scripts@"4.0.1" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\Leo\AppData\Local\npm-cache\eresolve-report.txt for 
a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Leo\AppData\Local\npm-cache\_logs\2021-08-07T10_27_10_092Z-debug.log

标签: javascriptreactjseslint

解决方案


根据您的日志,npm install似乎 type-fest 依赖项存在问题。您可以尝试运行npm install --save type-fest以将其保存到您的依赖项中,然后重试。


推荐阅读