I have always an error whenever I try to compile the new hardhat project even though I use the default contract (Lock.sol) coming with hardhat. I didn't change anything.

1- I created a new hardhat JS project on cmd by using npx hardhat

2- I downloaded the packages that hardhat is recommend. npm install --save-dev "hardhat@^2.11.1" "@nomicfoundation/hardhat-toolbox@^1.0.1"

3- I tried to compile npx hardhat compile

An unexpected error occurred:

Error: The specified module could not be found.
    at Object.Module._extensions..node (node:internal/modules/cjs/loader:1210:18)
    at Module.load (node:internal/modules/cjs/loader:1004:32)
    at Function.Module._load (node:internal/modules/cjs/loader:839:12)
    at Module.require (node:internal/modules/cjs/loader:1028:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (C:\Users\turgay\Desktop\SolidityProjects\emptyhardhatfinal\node_modules\@nomicfoundation\solidity-analyzer\index.js:69:29)
    at Module._compile (node:internal/modules/cjs/loader:1126:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
    at Module.load (node:internal/modules/cjs/loader:1004:32)
    at Function.Module._load (node:internal/modules/cjs/loader:839:12) {

My hardhat.config file:


/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
  solidity: "0.8.9",

My package.json:

  "name": "hardhat-project",
  "devDependencies": {
    "@nomicfoundation/hardhat-toolbox": "^1.0.2",
    "hardhat": "^2.11.1"

What is wrong? Thank you in advance..

  • Have you tried npx hardhat run scripts/deploy.js or node scripts/deploy.js if not please run and see if it is working or throwing the same error. And share errors.
    – Ad-h0c
    Sep 8, 2022 at 12:45

3 Answers 3


I have found similar problem while searching. See if this solution works for you.



Try installing hardhat using npm install --dev hardhat If you not need that particular version, otherwise the issue might be specific to the version itself


Here's a workaround to the Module_Not_Found compiling error. https://github.com/NomicFoundation/hardhat/issues/3176

  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Sep 14, 2022 at 10:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.