无法读取 Ethers 库中的属性

问题描述 投票:0回答:1

我尝试从 WSL 连接到 Ganache,但不知何故我收到此错误

TypeError: Cannot read properties of undefined (reading 'JsonRpcProvider')

ChatGPT 说这是因为你没有正确添加以太库或错误导入

这是我的导入代码

const ethers = require("ethers");
我也尝试一下
const { ethers } = require("ethers");

这是我的 json

{
  "dependencies": {
    "ethers": "^6.9.2",
    "fs": "^0.0.1-security",
    "fs-extra": "11.2.0",
    "ganache": "^7.9.2",
    "solc": "^0.8.7-fixed"
  },
  "scripts": {
    "compile": "yarn solcjs --bin --abi --include-path node_modules/ --base-path . -o . SimpleStorage.sol"
  }
}

我尝试添加库,但代码无法读取它

javascript typescript solidity
1个回答
0
投票

这里解答了 Solition

问题是此链接中的以太库版本显示了解决方案

© www.soinside.com 2019 - 2024. All rights reserved.