![](/img/trans.png)
[英]Cannot find module './App.svelte' or its corresponding type declarations
[英]Cannot find module 'hardhat/config' or its corresponding type declarations
我正在使用打字稿和纱线建立一个安全帽的新项目。
我正在关注https://hardhat.org/guides/typescript.html并且当我到达“我们需要对您的配置应用三个更改以使其与 TypeScript 一起工作: ”这一步时,有一条更新hardhat.config.js
的说明hardhat.config.js
到hardhat.config.ts
说明和示例代码说import { task } from "hardhat/config";
但是 vscode 和编译器说Cannot find module 'hardhat/config' or its corresponding type declarations.
我错过了什么?
也许将此导入添加到您的安全帽配置文件中?
import { HardhatUserConfig, task } from "hardhat/config";
并小心安装所有必要的类型:
import "@nomiclabs/hardhat-etherscan";
import "@nomiclabs/hardhat-waffle";
import "@typechain/hardhat";
import "hardhat-gas-reporter";
import "solidity-coverage";
我也有同样的问题。 然后我尝试使用npm
而不是yarn
包管理器,错误得到解决。
我建议卸载并重新安装 yarn并检查错误是否得到解决,或者改用npm
包管理器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.