我正在尝试使用安全帽编译此智能合约,但收到此错误
npx 安全帽编译
contracts/FlashSwap.sol:7:1: ParserError: Source "node_modules/hardhat/console.sol" not
found: File outside of allowed directories.
import "../node_modules/hardhat/console.sol";
^-------------------------------------------^
Error HH600: Compilation failed
The thing is I already have this in first line of my code and still getting the error
//SPDX-License-Identifier: Unlicense
pragma solidity >=0.6.6;
import "../node_modules/hardhat/console.sol";
您不应在导入语句中添加
node_modules
。
更改以下行:
import "../node_modules/hardhat/console.sol";
进入以下行:
import "hardhat/console.sol";
发生这种情况是因为 package.json 中的名称条目是“hardhat”。将其更改为其他内容应该可以解决问题。