在纱线中安装所有未满足的依赖项

Posted

技术标签:

【中文标题】在纱线中安装所有未满足的依赖项【英文标题】:Install all unmet dependencies in yarn 【发布时间】:2021-02-09 01:26:08 【问题描述】:

我的反应应用程序有错误,它说:

    Line 0:  Parsing error: Cannot find module 'eslint-scope' from '/home/path/.cache/yarn/v6/npm-eslint-7.11.0-aaf2d23a0b5f1d652a08edacea0c19f7fadc0b3b-integrity/node_modules/eslint/lib/api.js'

然后我使用以下命令将 eslint-scope 添加到我的依赖项中:

    yarn add eslint-scope

但我发现了很多未满足的对等依赖项:

    warning " > @testing-library/user-event@12.1.10" has unmet peer dependency "@testing-library/dom@>=7.21.4".
    warning " > eslint-config-react-app@6.0.0" has unmet peer dependency "@typescript-eslint/eslint-plugin@^4.0.0".
    warning " > eslint-config-react-app@6.0.0" has unmet peer dependency "@typescript-eslint/parser@^4.0.0".
    warning " > eslint-config-react-app@6.0.0" has unmet peer dependency "babel-eslint@^10.0.0".
    warning " > eslint-config-react-app@6.0.0" has unmet peer dependency "eslint-plugin-flowtype@^5.2.0".
    warning " > eslint-config-react-app@6.0.0" has unmet peer dependency "eslint-plugin-import@^2.22.0".
    warning " > eslint-config-react-app@6.0.0" has unmet peer dependency "eslint-plugin-jsx-a11y@^6.3.1".
    warning " > eslint-config-react-app@6.0.0" has unmet peer dependency "eslint-plugin-react@^7.20.3".
    warning " > eslint-config-react-app@6.0.0" has unmet peer dependency "eslint-plugin-react-hooks@^4.0.8".

当我尝试安装其中一个时,我发现了另一个未满足的依赖项:

    warning " > @testing-library/user-event@12.1.10" has unmet peer dependency "@testing-library/dom@>=7.21.4".
    warning " > eslint-config-react-app@6.0.0" has unmet peer dependency "@typescript-eslint/eslint-plugin@^4.0.0".
    warning " > eslint-config-react-app@6.0.0" has unmet peer dependency "@typescript-eslint/parser@^4.0.0".
    warning " > eslint-config-react-app@6.0.0" has unmet peer dependency "eslint-plugin-flowtype@^5.2.0".
    warning " > eslint-config-react-app@6.0.0" has unmet peer dependency "eslint-plugin-import@^2.22.0".
    warning " > eslint-config-react-app@6.0.0" has unmet peer dependency "eslint-plugin-jsx-a11y@^6.3.1".
    warning " > eslint-config-react-app@6.0.0" has unmet peer dependency "eslint-plugin-react@^7.20.3".
    warning " > eslint-config-react-app@6.0.0" has unmet peer dependency "eslint-plugin-react-hooks@^4.0.8".

我可以自动安装所有不满足的依赖项吗?

【问题讨论】:

【参考方案1】:

首先你应该通过运行这个命令yarn why eslint-scope来找出为什么需要eslint-scope

如果您仍然认为需要它,那么您应该知道默认情况下不再安装对等依赖项。 You can read more about it here。在 NPM V7 中 peerDependencies 是 installed automatically again。

现在你应该尝试使用install-peerdeps 包npx install-peerdeps -Y eslint-scope

【讨论】:

以上是关于在纱线中安装所有未满足的依赖项的主要内容,如果未能解决你的问题,请参考以下文章

如何使用 requirements.txt 在 python 项目中安装所有依赖项

在 Angular 10 中安装缺少的依赖项

安装带有纱线的软件包时,“未满足对等依赖性”是啥意思?

Rails 6 无法导入纱线依赖项:未捕获错误:模块解析失败:意外字符“#”(1:0)

在 Elixir 中安装依赖项

在 React 项目中安装依赖项问题时面临问题