Cannot find module 'hardhat/config' or its corresponding type declarations

Viewed 2572

I'm setting up a new project with hardhat, using typescript and yarn.

I'm following https://hardhat.org/guides/typescript.html and when I get to the step "We need to apply three changes to your config for it to work with TypeScript:" there is an instruction to update the hardhat.config.js to hardhat.config.ts

The instructions and the example code say to put import { task } from "hardhat/config"; but vscode and the compiler say Cannot find module 'hardhat/config' or its corresponding type declarations.

What am I missing?

1 Answers

Maybe add this import to your hardhat config file?

import { HardhatUserConfig, task } from "hardhat/config";

And be careful to install all necessary types:

import "@nomiclabs/hardhat-etherscan";
import "@nomiclabs/hardhat-waffle";
import "@typechain/hardhat";
import "hardhat-gas-reporter";
import "solidity-coverage";
Related