【问题标题】:Error when trying to install a gatsby plugin尝试安装 gatsby 插件时出错
【发布时间】:2021-12-24 15:06:32
【问题描述】:

尝试安装plugin-gatsby-react-helment时出现以下错误

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: gatsproject@1.0.0
npm ERR! Found: gatsby@3.14.6
npm ERR! node_modules/gatsby
npm ERR!   gatsby@"^3.11.1" from the root project
npm ERR!
npm ERR! peer gatsby@"^4.0.0-next" from gatsby-plugin-react-helmet@5.4.0
npm ERR! node_modules/gatsby-plugin-react-helmet
npm ERR!   gatsby-plugin-react-helmet@"*" 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\Asus\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\Asus\AppData\Local\npm-cache\_logs\2021-12-24T14_44_33_845Z-debug.log

但是 react-helmet 安装得很好 我一无所知

【问题讨论】:

  • 它可能来自您的缓存。转到此目录( C:\Users\Asus\AppData\Local\ )并删除“npm-cache”然后重试

标签: gatsby gatsby-plugin


【解决方案1】:

这是不言自明的。

您已经安装了一个 Gatsby 版本 ^3.11.1,因为它是从以下位置提取的:

npm ERR!   gatsby@"^3.11.1" from the root project

虽然gatsby-plugin-react-helmet 原样,但没有特定版本会尝试安装最新版本 (5.4.0)。此最新版本需要 Gatbsby 第 4 版(主要更新),因为它是从以下位置提取的:

npm ERR! peer gatsby@"^4.0.0-next" from gatsby-plugin-react-helmet@5.4.0
npm ERR! node_modules/gatsby-plugin-react-helmet
npm ERR!   gatsby-plugin-react-helmet@"*" from the root project

也就是说,根据您的规格,您有两种选择:

第二个对您的项目的影响较小,但理想情况下,您迟早需要升级 Gatsby 版本。

我想,作为较低的主要更新,gatsby-plugin-react-helmet 插件的任何版本 4 都应该可以工作。如果没有,请尝试降低版本。

记得在每次试用时清理缓存(使用gatsby clean)。

【讨论】:

    猜你喜欢
    • 2019-05-27
    • 2014-09-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-15
    • 2017-10-11
    • 2015-01-17
    • 2013-11-13
    相关资源
    最近更新 更多