无法读取 ether.js 中未定义的属性(读取“toHexString”)

por*_*osh 5 javascript blockchain

请不要判断,我不知道该做什么以及如何做:)

我的代码: ether.js(^5.6.0)

import { ThirdwebSDK } from '@3rdweb/sdk'
import { ethers } from 'ethers'

const sdk = new ThirdwebSDK(
  new ethers.Wallet(
    process.env.METAMASK_PRIVATE_KEY,
    ethers.getDefaultProvider(
      'https://rinkeby.infura.io/v3/'
    )
  ) 
)
Run Code Online (Sandbox Code Playgroud)

漏洞 在此输入图像描述

小智 10

如果您使用 JavaScript 并收到此错误,则说明您在导入 dotenv 时犯了错误。您正在使用“.config”作为属性。像下面这样的方法使用它

需要(“dotenv”).config()

它会起作用的。