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

@nomicfoundation/hardhat-ethers与@openzeppelin/hardhat-upgrades ethers版本冲突

解决@nomicfoundation/hardhat-ethers的ethers版本冲突问题

安装@nomicfoundation/hardhat-ethers时出现ethers版本依赖冲突,使用npm update和强制安装操作均无法解决问题,需要更换为兼容版本,以下是明确的版本对应关系和操作步骤:

  • 必须使用兼容版本,@nomicfoundation/hardhat-ethers对ethers有严格的peer依赖约束
  • 当前兼容版本对应关系:
    • @nomicfoundation/hardhat-ethers v3.x → ethers v6.x
    • @nomicfoundation/hardhat-ethers v2.x → ethers v5.x

具体操作步骤

  1. 先卸载现有冲突的包:
    npm uninstall ethers @nomicfoundation/hardhat-ethers
    
  2. 选择对应组合安装:
    • 安装v3版本搭配ethers 6:
      npm install ethers@6 @nomicfoundation/hardhat-ethers@3
      
    • 或者安装v2版本搭配ethers 5:
      npm install ethers@5 @nomicfoundation/hardhat-ethers@2
      

补充:若项目中还有其他依赖ethers的包,优先选择匹配项目整体依赖的版本组合;也可以查看@nomicfoundation/hardhat-ethers包的package.json文件里的peerDependencies字段,确认官方要求的ethers版本范围。

内容的提问来源于stack exchange,提问作者Shubhankar Banerjee

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.04 12:47:19