'Error HH12: Trying to use a non-local installation of Hardhat, which is not supported
I have installed hardhat properly because when I type
npx hardhat for, first time, it allows me to create the config.js files and sample projects.
The problem is I can't use the hardhat after that first command, and it keeps giving me the below error:
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 can't compile or do anything, and I have installed it and reinstalled it on new projects several times using only sample files, and still the same error.
So after that, if I do any npx hardhat compile or npx hardhat alone, I get the above error.. what can be the problem. it seems to get this error after generating the config.js file
I have tried only NextJS and hardhat ethers/waffle etc. dependencies installed on a fresh install.
Solution 1:[1]
Had the same issue over the last two days while trying to install Hardhat in a cloned repository using VS Code. This worked for me using the Powershell terminal.
In the project folder, use npm ls to check if Hardhat is already installed.
Then npm -g ll to check for a global installation, if it exists run npm uninstall hardhat then exit the terminal (and VS Code).
Repeat the above checks in a new terminal to ensure the uninstall is complete. Create a new folder and follow the installation process as per the Hardhat docs, i.e:
npm init -ynpm install --save-dev hardhatnpx hardhat("create a simple project")npm install --save-dev @nomiclabs/hardhat-waffle ethereum-waffle chai @nomiclabs/hardhat-ethers ethers
Run npx hardhat to see if it works.
Solution 2:[2]
Hey i had figured it out but let me post the solution for others struggling.
The simple solution is to check the case when using Terminal. the folder names and directories are case-sensitive.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | William Balaile |
| Solution 2 | evilguyme |
