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:
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
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:
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
Uninstall any global version of hardhat
Remove node_modules and run npm install or yarn install to install all dependencies.
Try running npx hardhat compile or npx hardhat node to check if it works.
Try to not run hardhat using npx hardhat ..., run it locally using npm hardhat ... or yarn hardhat ..., other thing that can cause this error on windows is the git bash, if you are using the git bash you won't be able to run hardhat in that case try what running it locally with npm or yarn in the cmd
I had the same issue. What I did was run the following commands:
npm install --save-dev "hardhat#^2.10.1
npm i #nomicfoundation/hardhat-toolbox
Don't make directories/folder structure manually, instead do it by using mkdir command from vscode terminal. This way you will not face this HH12 error.
I recently created several DAPPs and I had never faced this problem again.
mkdir Whitelist-Dapp
cd Whitelist-Dapp
mkdir hardhat-files
cd hardhat-files
npm init --yes
npm install --save-dev hardhat
First thing to check when this error comes up is whether you are running
npx run scripts/deploy.js --network localhost
in the correct path or not. It should run from directory where you have put hardhat.config.js file.
To fix this problem, go into your terminal and write nvm use 17. It will switch the node back to 17. The problem is that you may have inadvertently updated your hardhat version so you have 2 versions running on your machine.
You can also check whether traces tell you something (npx hardhat --show-stack-traces). I tried reinstalling nvm, node, searched whole PC for anything that has hardhat within file name and deleted it.
In the end I was missing some packages in my project...
In my case I had a problem with the package-lock.json
I deleted the package-lock.json file and then ran the command
npm install
That solved the problem for me.
I found a way to avoid this issue by typing the commands in the following sequence. I think it has something to do with when you install your Hardhat in the folder.
I am creating my project in the directory called JACKPOT, and then I type the commands in the following order. So far so good.
Frist create your project folder and then switch to it:
PS C:\Users\alanh> mkdir jackpot
PS C:\Users\alanh> cd jackpot
Then, start VS Code in that folder by typing the following command:
PS C:\Users\alanh\jackpot> code .
Then, add Hardhat to your projet and start the project:
PS C:\Users\alanh\jackpot> yarn add --dev hardhat
PS C:\Users\alanh\jackpot> yarn add --dev hardhat
Hope this helps. Cheers!
I did unstalled nodejs and delted all unrequired file and folder related to hardhat from C:\Users\user and reinstalled all thing, it worked for me ,
I am trying to install sass and I don't understand why I keep running into the issue shown below
I understand I should follow the instructions and run npm audit fix but when I run the command, I get an error of no package.json found, and yes, that is so because sass wasn't installed at all and thus no node-modules and the json file, how do I fix this issue?
Try running the npm init command at the root of your project to generate the package.json file and re run the command to install sass.
Please find the stack over here...
Installing packages...npm WARN deprecated tslint#6.1.2: TSLint has been deprecated in favor of ESLint. Please see https://github.com/palantir/tslint/issues/4534 for more information.
npm WARN deprecated request#2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated chokidar#2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated fsevents#1.2.12: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
npm WARN deprecated urix#0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated resolve-url#0.2.1: https://github.com/lydell/resolve-url#deprecated
npm ERR! Unexpected end of JSON input while parsing near '...iERRHPyU8nBqZB1+iv2Uh'
I had the exact same error and was able to fix it through following steps.
Run npm cache clean --force
Manually delete npm and npm-cache folders from AppData/Roaming folder (Win + R, Type %AppData% and enter)
Run Node Installer and repair
Reinstall npm install -g #angular/cli
Rerun ng new newApp
Worked :)
Use node V12.4.0 and npm V6.9.0
i was getting the same issue please try reinstall angular CLI after installing previous one
I think this can only be achieved if we first update the version to 8 and then move from 8 to 9.
I had the same Issue and Following steps worked for me.
Delete npm-cache in AppData/Roaming
Reinstall the angular cli by 'npm install -g #angular/cli'
Then Create the project
Run npm cache clean --force
Manually delete npm and npm-cache folders from AppData/Roaming folder (Win + R, Type %AppData% and enter)
Run Node Installer and repair
4.Reinstall npm install -g #angular/cli
Rerun ng new newApp
Worked :)
https://github.com/npm/cli/issues/1191
Delete the AppData\Roaming\npm-cache folder and then try creating the project again. This is really gonna work =)
I have been trying to run npm install to update my node modules,but couldn't !,none of the similar solutions work for me.
This is the error that I am getting:
Try to Remove cache using npm cache clean --force and try again.
So i've been creating a desktop application using electron. The problem is that when I run my application using npm it doesn't show any error about a missing module but when i package it and run it this error shows
I'm sure that i've install mysql module using npm install -g mysql and npm install mysql in the project directory. It's all working fine when i run the unpacked version of the application
Assuming that you have installed mysql if not please install mysql npm install mysql --save-dev
Hi I also ran in same error I tried everything possible but nothing seems to work , after several hit and trial I was able to fix it and in the end realize that it was all happening because of
When I installed MySQL module I never saved it (--save-dev)
And electron-packager was not able to locate it when I pack it because was not mention in package.json
A solution might locate mysql folder in node_module folder and delete
then install it npm install mysql --save-dev
or manually
add it under dependencies in package.json file