Search code examples
ethereumchainlinkhardhat

Error HH12: Trying to use a non-local installation of Hardhat, which is not supported. Please install Hardhat locally using npm or Yarn, and try again


I've been working on a Hardhat project for sometime.
After a while, when I run npx hardhat node to start the HH server, I get the error below:

This is an image of the error

I tried researching the error and found this on the hardhat site

   HH12: Hardhat is not installed or installed globally
    You tried to run Hardhat from a global installation or not installing it at all. This is not supported.

Please install Hardhat locally using npm or Yarn, and try again.

Funny enough, I created a new HH project and installed everything afresh
then imported my code into the new project and this seemed to solve the problem...
but after sometime, the issue began again.
I can't keep creating a new project each time this happens.
I've been stuck for days now and will appreciate any help.

OS: windows10


Solution

  • Do not install Hardhat globally. If you already have installed hardhat globally, please uninstall as the issue might be because of that as mentioned in the error message.

    Things you need to do to mitigate this:

    1. Check if the project package.json has hardhat as its dev dependency. If it is not, run npm install --save-dev hardhat or yarn add --dev hardhat
    2. Uninstall any global version of hardhat
    3. Remove node_modules and run npm install or yarn install to install all dependencies.
    4. Try running npx hardhat compile or npx hardhat node to check if it works.