'Npx hardhat could not determine executable to run
I am trying to follow this guide and I am struggling running hardhat. After following the commands in the article:
mkdir hardhat-tutorial
cd hardhat-tutorial
npm init --yes
npm install --save-dev hardhat
npx hardhat
I get an error stating npm ERR! could not determine executable to run
. The hardhat tool can be run by navigating to the npm_modules/hardhat
directory however this seems to be interfering with the commands later in the tutorial due to the tool being in a different directory to the files it is being used on.
I'm not sure if I have fundamentally misunderstood how hardhat is supposed to work. Are you supposed to install it in each project and have your project directory be within npm_modules/hardhat
or have I messed up the install/configuartion?
There appears to have already been a question covering this issue but sadly it was deleted and I have not managed to find another solution.
Solution 1:[1]
I had the same issue then it worked for me by specifying the latest version of hardhat during the install, eg.:
npm install --save-dev "hardhat@^2.8.0"
With this no need to go into the node_modules/hardhat
folder in order to run npx hardhat
Solution 2:[2]
To address all issues (including breaking changes), run:
npm audit fix --force
Run npm audit
for details.
dee-MacBook-Pro-2 polygon-hardhat % npm audit fix --force
npm WARN using --force Recommended protections disabled.
npm WARN audit Updating hardhat to 0.0.7,which is a SemVer major change.
npm WARN deprecated [email protected]: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
added 4 packages, removed 333 packages, changed 5 packages, and audited 10 packages in 4s
found 0 vulnerabilities
dee@Dee-MacBook-Pro-2 polygon-hardhat % npx hardhat
npm ERR! could not determine executable to run
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/dee/.npm/_logs/2022-02-13T16_54_02_999Z-debug-0.log
dee@Dee-MacBook-Pro-2 polygon-hardhat %
Solution 3:[3]
The best thing to do is create a new hardhat project, because here and there you will get stuck. Faced the same problem
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 | Waƫl Nasr |
Solution 2 | betelgeuse |
Solution 3 |