sh: hardhat: command not found when installing Hardhat

Viewed 1118

Trying to build a project with Hardhat, I have node v15.14.0, and ran the following commands:

npm init -y

npm install --save-dev hardhat

Terminal gives me:

enter image description here

Then I ran:

npx hardhat

But got an error saying:

sh: hardhat: command not found

2 Answers

You should use NPX. The Node Package eXecute allows us to directly access and execute a package stored (or not) in $ ./node_modules/.bin/your-package.

Using npx hardhat [GLOBAL OPTIONS] <TASK> everything will works fine!

Running npm install --save-dev hardhat again did it for me.

Related