无法读取未定义的属性(读取“parseUnits”) - Hardhat js

Moe*_*jac 3 javascript chai solidity ethers.js hardhat

当尝试在测试函数中使用时,ethers.utils.parseUnits("1", "ether")会引发错误TypeError: Cannot read properties of undefined (reading 'parseUnits')

const { deployments, ethers, getNamedAccounts } = require("hardhat")
const { assert, expect } = require("chai")
describe("FundMe", async function () {
    let fundMe
    let deployer
    const sendValue = ethers.utils.parseUnits("1", "ether")
})
Run Code Online (Sandbox Code Playgroud)

我也尝试过使用 parseEther 得到相同的结果。在ethers.utils.parseUnits 的文档规范中,它说只使用它。我还缺少其他功能吗?我的以太配置可能不正确吗?

Moe*_*jac 7

以太坊版本 6 ethers.utils.parseUnit()开始,已被替换为ethers.parseUnit()