When I run the following commands:

  • Terminal 1: npx hardhat node
  • Terminal 2: npx hardhat run scripts/sample-script.js --network localhost

I see the blockchain node created on terminal 1 execute things as I'd expect: enter image description here

But if I run the following commands:

  • Terminal 1: npx hardhat node (no changes)
  • Terminal 2: node scripts/sample-script.js --network localhost

I see no activity on Terminal 1.

So what's the difference between node /* ... */ and npx hardhat run /* ... */?

I'm running the standard sample-script.js (pasted below without its original comments):

const hre = require("hardhat");

async function main() {
  const Greeter = await hre.ethers.getContractFactory("Greeter");
  const greeter = await Greeter.deploy("Hello, Hardhat!");

  await greeter.deployed();

  console.log("Greeter deployed to:", greeter.address);

  .then(() => process.exit(0))
  .catch((error) => {

1 Answer 1


npx hardhat node and npx hardhat run are both tasks that come by default in hardhat. You can check all defined tasks with the following commands: npx hardhat or npx hardhat help.

enter image description here

Here you have that:

  • node: Starts a JSON-RPC server on top of Hardhat EVM;
  • run: Runs a user-defined script after compiling the project

You can also create your own tasks. Take a look at the docs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.