纱线安全帽测试 -> JSON 输入意外结束



我是纱线新手。我以前用npm开发过solid程序。当我尝试使用纱线和yarn hardhat test。有一个错误:

An unexpected error occurred:
SyntaxError: Error parsing /Users/xy/Desktop/program/test_test/node_modules/loupe/package.json: Unexpected end of JSON input
at parse (<anonymous>)
at readPackage (node:internal/modules/cjs/loader:304:20)
at resolveExports (node:internal/modules/cjs/loader:479:15)
at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/Users/xy/Desktop/program/test_test/node_modules/chai/lib/chai/utils/inspect.js:5:13)
at Module._compile (node:internal/modules/cjs/loader:1103:14) {
path: '/Users/xy/Desktop/program/test_test/node_modules/loupe/package.json'
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

但我使用的是全新的硬帽演示,yarn hard compile是可以的。如果我使用npm

也是可以的下面是演示脚本:
import { expect } from "chai";
import { ethers } from "hardhat";
describe("Greeter", function () {
it("Should return the new greeting once it's changed", async function () {
const Greeter = await ethers.getContractFactory("Greeter");
const greeter = await Greeter.deploy("Hello, world!");
await greeter.deployed();
expect(await greeter.greet()).to.equal("Hello, world!");
const setGreetingTx = await greeter.setGreeting("Hola, mundo!");
// wait until the transaction is mined
await setGreetingTx.wait();
expect(await greeter.greet()).to.equal("Hola, mundo!");
});
});

这似乎是chai的问题,因为当我删除expect行时问题消失了。

第一步:

runnpx hardhat clean

第二步:

自动编译

相关内容

  • 没有找到相关文章

最新更新