我目前正在 WSL 上运行最新版本的 Hardhat。我按照hardhat给出的演示安装了hardhat工具箱的npm包。 但是,它显示了一些我不明白的错误。
最初,我使用“const”和“require”格式。然后我更改为“导入”格式
通常,imports() 用于“.mjs”模块中。所以我想也许我必须将“类型”更改为“模块”。但这也不起作用,正如您在第三次迭代中看到的那样。在此处输入图像描述
另一个有趣的部分是“node_modules/chai/index.mjs”已经在使用 import 语句!
请指导我接下来该怎么做。
以下是我的脚本文件。
// const {ethers} = require("hardhat")
// const {expect} = require("chai")
import {expect} from 'chai'
import {ethers } from 'hardhat'
describe("SafeHeiro Base Implementation", function(){
it("Should correctly assign the value '3' to 'Test' key", async function () {
const safeHeiro = await ethers.deployContract('safeHeiro')
await safeHeiro.waitForDeployment()
await safeHeiro.callThis()
expect(await safeHeiro.getValueOfThis()).to.equal(3)
})
})