'sh: hardhat: command not found when installing Hardhat

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



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source