使用安全帽编译智能合约时出错

问题描述 投票:0回答:2

我正在尝试使用安全帽编译此智能合约,但收到此错误

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";
javascript node.js ethereum solidity hardhat
2个回答
0
投票

您不应在导入语句中添加

node_modules

更改以下行:

import "../node_modules/hardhat/console.sol";

进入以下行:

import "hardhat/console.sol";

0
投票

发生这种情况是因为 package.json 中的名称条目是“hardhat”。将其更改为其他内容应该可以解决问题。

© www.soinside.com 2019 - 2024. All rights reserved.