Sign in
Log inSign up
code:
'MODULE NOT FOUND',
requirestack:
"/Users/rootdirectory/hardhat.config.js' (What happened and how I fixed it)

code: 'MODULE NOT FOUND', requirestack: "/Users/rootdirectory/hardhat.config.js' (What happened and how I fixed it)

Orlundo Hubbard's photo
Orlundo Hubbard
·Nov 27, 2021·

3 min read

Recently I have been diving head-first into blockchain technology and everything Web3. Since I've drunk the kool-aid and joined the community about a month ago, it has been nothing short of amazing. I joined my first DAO (the Developer DAO - highly recommend) and since then I have learned so much. I recently started building projects with the ever-growing Web3 platform " BuildSpace " (also highly recommend) and I'm currently building the project that teaches you to create and mint your own NFT.

During the project, one of the steps requires you to install "hardhat".

What is Hardhat?

Put simply, Hardhat is basically an environment that allows you to test, compile, and deploy your smart contracts and dApps. It also comes with a built-in local network called the "Hardhat network" that uses Ethereum as its local network. Hardhat makes the workflow easier for a smart contract developer during the development process.

First, I installed hardhat by running

npm install --save-dev hardhat

When I ran this command in the terminal, here is what I received Screen Shot 2021-11-24 at 9.22.11 AM.png

When I saw this, I knew something must have gone wrong 🤦🏾‍♂️. Simply because I knew, I had just run this command on another project with different results. What confirmed my suspicions is when I ran the command npx hardhat . Once this command was run, everything broke. Here is the result below

Screen Shot 2021-11-24 at 3.12.57 PM.png

So, what happened? 🤷🏾‍♂️

Well, first let's look at the first error Screen Shot 2021-11-26 at 8.09.17 PM.png

What it was basically telling me was that it could not find one of the important modules needed for Hardhat to run properly

@nomiclabs/hardhat-waffle

I won't get into detail about waffle, but I definitely suggest looking up what it is. So, I tried to run npm install @nomiclabs/hardhat-waffle because I thought the dependency just needed to be added and that would fix the problem. But that did not work. Ok, moving forward. Let's turn our attention to the next issue that was given (which was kind of a part of the same error).

'MODULE NOT FOUND',
requirestack:
"/Users/orlundohubbard/hardhat.config.js'

What this was telling me was that there was already a hardhat configuration built globally that was conflicting with the one that I was trying to build locally. With that, I learned not to install hardhat globally. But it also told me where that global hardhat installation was...it was in my user directory, which for me was "orlundohubbard". Ok, we figured that out. Now what?

How I fixed it...

First, I want to give a huge s/o to a developer by the name of Camila who is also a part of the Developer DAO. She was so gracious and kind to take time out of her day and hop on a call with me to solve this issue. What was causing me to rack my brain for the past 2 days literally took her like 10 minutes to debug. She's brilliant! Turns out, it was quite the easy fix lol.

What I had to do was go inside of my user directory (orlundohubbard) and find the hardhatconfig.js file that was installed globally. Once I found it, I deleted it. After that, I ran npm install --save-dev hardhat again. It ran smoothly this time. Next, I ran npx hardhat again and BAM! IT WORKED! That was such a relief because I thought that I had run across an unfixable problem. But I was once told by a wise developer "there's no hole that you can't be dug out of".

Thanks to Camila and the Developer DAO for creating such a welcoming environment to grow and learn the Web3 space as a new developer! Looking forward to more errors to write about and how to fix them! haha!