How to Install Hardhat on Linux Mint 22

Hardhat is a popular Ethereum development environment that allows developers to compile, deploy, test, and debug smart contracts. If you’re using Linux Mint 22 and want to install Hardhat, follow this step-by-step guide.

Step 1: Update Your System

Before installing Hardhat, update your system to ensure all packages are up to date. Open a terminal and run:

sudo apt update && sudo apt upgrade -y

Step 2: Install Node.js and npm

Hardhat requires Node.js and npm (Node Package Manager). Install them using:

sudo apt install nodejs npm -y

Verify the installation by checking the versions:

node -v
npm -v

If you need the latest version of Node.js, use:

curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo bash -
sudo apt install -y nodejs

Step 3: Install Hardhat

Navigate to your project folder or create a new one:

mkdir hardhat-project && cd hardhat-project

Initialize a new Node.js project:

npm init -y

Then, install Hardhat:

npm install --save-dev hardhat

Step 4: Set Up a Hardhat Project

Run the following command to create a new Hardhat project:

npx hardhat

Select the desired setup options and Hardhat will generate the required files.

Step 5: Verify the Installation

To confirm that Hardhat is installed correctly, run:

npx hardhat --version

If it prints a version number, Hardhat has been installed successfully.

Troubleshooting

  • If you encounter permission errors, try installing Hardhat globally: sudo npm install -g hardhat
  • If the npx command is not found, ensure that npm is installed correctly by running npm -v.