When I want to import ethers
from hardhat
it throws the error that I mentioned in the title here is a complete version
- error TS2305: Module '"hardhat"' has no exported member 'ethers'.
2 import { ethers } from "hardhat";
~~~~~~
Although I used it the same way in my previous projects and seen everyone doing the same
CodePudding user response:
They likely dont explicitly export ethers. In the Documentations it shows using ethers in the following way:
import hre from "hardhat";
const Lock = await hre.ethers.getContractFactory("Lock");
https://hardhat.org/hardhat-runner/docs/guides/test-contracts
CodePudding user response:
I had to add these two lines to tsconfig.json
"include": ["./test", "./src", "./scripts"],//only the "scripts" part.
"files": ["./hardhat.config.ts"]