reactjstypescripthardhat

Module '"hardhat"' has no exported member 'ethers'


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


Solution

  • I had to add these two lines to tsconfig.json

      "include": ["./src", "./scripts"],//only the "scripts" part.
      "files": ["./hardhat.config.ts"]