HardHat:无需编译

Ng *_*rma 2 npm ethereum solidity hardhat

当编译安全帽项目时,当它显示Nothing to Compile时。

{
  "name": "HardhAtToken",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@nomiclabs/hardhat-ethers": "^2.0.6",
    "@nomiclabs/hardhat-waffle": "^2.0.3",
    "chai": "^4.3.6",
    "ethereum-waffle": "^3.4.4",
    "ethers": "^5.6.6",
    "hardhat": "^2.9.6-dev.1"
  },
  "dependencies": {
    "glob": "^7.2.0"
  }
}
Run Code Online (Sandbox Code Playgroud)

Pet*_*jda 7

Hardhat 在项目文件夹中保存已编译合约的缓存cache

npx hardhat compile命令仅编译自上次编译以来未更改的文件。因此,在您的情况下,预计会出现“无需编译”消息。

您可以使用 清除缓存npx hardhat clean,或使用参数强制重新编译缓存的源npx hardhat compile --force

文档: https: //hardhat.org/guides/compile-contracts.html