'config error : Invalid value undefined for HardhatConfig.networks.paths.url

this is my hardhat.config.js file code :

require("@nomiclabs/hardhat-waffle");

// This is a sample Hardhat task. To learn how to create your own go to
// https://hardhat.org/guides/create-task.html
task("accounts", "Prints the list of accounts", async (taskArgs, hre) => {
  const accounts = await hre.ethers.getSigners();

  for (const account of accounts) {
    console.log(account.address);
  }
});

// You need to export an object to set up your config
// Go to https://hardhat.org/config/ to learn more

/**
 * @type import('hardhat/config').HardhatUserConfig
 */
module.exports = {
  solidity: "0.8.4",
  networks : {
    hardhat :{
      chainId: 1337,
    },
  
  paths :{
    artifacts: "./src/artifacts",
  },
},
};

and when i compile this using npx hardhat compile

it shows following error :

Error HH8: There's one or more errors in your config file:

  • Invalid value undefined for HardhatConfig.networks.paths.url - Expected a value of type string.

To learn more about Hardhat's configuration, please go to https://hardhat.org/config

for your reference i am following this tutorial for building this web3 project : "https://blog.suhailkakar.com/setup-and-build-your-first-web-3-application"



Solution 1:[1]

You have to close the network's bracket after the hardhat chain Id :)

Please replace your module.exports object with this

module.exports = {
  solidity: "0.8.4",
  networks:{
    hardhat:{
      chainId: 1337,
    }
  },
  paths:{
    artifacts: "./src/artifacts"
  }
};

P.S: Thanks for pointing this out, I have also updated my article

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 Suhail Kakar