简体   繁体   中英

Errror compiling smart contract using hardhat

I am trying to compile this smart contract using hardhat and I am getting this error

npx hardhat compile

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";

You should not add node_modules in the import statement.

Change the following line:

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

Into the following line:

import "hardhat/console.sol";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM