0

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.
\\?\C:\Users\turgay\Desktop\SolidityProjects\emptyhardhatfinal\node_modules\@nomicfoundation\solidity-analyzer-win32-x64-msvc\solidity-analyzer.win32-x64-msvc.node
    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) {
  code: 'ERR_DLOPEN_FAILED'
}

My hardhat.config file:

require("@nomicfoundation/hardhat-toolbox");

/** @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..

1
  • 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

0

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

MODULE_NOT_FOUND

0

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

0

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

1
  • 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.