You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Gatsby 5.12.3存在@typescript-eslint/eslint-plugin对等依赖冲突求助

Gatsby 5.12.3 对等依赖冲突问题及临时解决办法

我在使用Gatsby 5.12.3时碰到了**对等依赖冲突(conflicting peer dependency)**错误,根源是@typescript-eslint/eslint-plugin的版本要求不兼容:

依赖链冲突详情

gatsby (5.12.3)
--- "@typescript-eslint/eslint-plugin": "^5.60.1",
--- "eslint-config-react-app": "^6.0.0",
   --- "@typescript-eslint/eslint-plugin": "^4.0.0",
  • Gatsby 5.12.3本身依赖@typescript-eslint/eslint-plugin的^5.60.1版本
  • 同时Gatsby依赖的eslint-config-react-app@6.0.0,要求该插件版本为^4.0.0
  • 当前@typescript-eslint/eslint-plugin最新版本为^6.4.1,但同样无法适配现有依赖链的版本要求

临时解决方法

目前唯一能让项目正常安装和运行的方式,是在执行依赖安装或启动命令时添加--legacy-peer-deps参数:

# 安装依赖
npm install --legacy-peer-deps
# 或者使用yarn
yarn install --legacy-peer-deps

# 启动项目时也可能需要添加
npm run develop --legacy-peer-deps

可选的彻底尝试方向

如果不想一直依赖--legacy-peer-deps,可以试试以下方案(需自行测试兼容性):

  • 等待Gatsby官方更新依赖,将eslint-config-react-app升级到兼容@typescript-eslint/eslint-plugin@^5.60.1的版本
  • 在package.json中使用overrides字段(npm 8+支持)强制统一插件版本:
{
  "overrides": {
    "@typescript-eslint/eslint-plugin": "^5.60.1"
  }
}

注意:强制覆盖版本可能导致eslint-config-react-app出现运行异常,需要验证ESLint规则是否能正常工作。

内容的提问来源于stack exchange,提问作者Michael Sync

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.12 01:43:16