1
Error:
Error HH19: Your project is an ESM project (you have "type": "module" set in your package.json) but your Hardhat config file uses the .js extension.

Rename the file to use the .cjs to fix this problem.

Renaming the file to .cjs didn't work and couldn't find "type": "module" file.

Package.json:

{
  "devDependencies": {
    "@chainlink/contracts": "^0.8.0",
    "@nomicfoundation/hardhat-chai-matchers": "1",
    "@nomicfoundation/hardhat-network-helpers": "^1.0.10",
    "@nomicfoundation/hardhat-toolbox": "^4.0.0",
    "@nomiclabs/hardhat-ethers": "^2.2.3",
    "@nomiclabs/hardhat-etherscan": "^3.1.8",
    "@typechain/ethers-v6": "^0.5.1",
    "@typechain/hardhat": "^9.1.0",
    "chai": "^5.0.0",
    "dotenv": "^16.3.1",
    "ethers": "5",
    "hardhat": "^2.19.4",
    "hardhat-contract-sizer": "^2.10.0",
    "hardhat-deploy": "^0.11.45",
    "hardhat-gas-reporter": "^1.0.9",
    "prettier": "^3.1.1",
    "prettier-plugin-solidity": "^1.3.1",
    "solhint": "^4.0.0",
    "solidity-coverage": "^0.8.5",
    "typechain": "^8.3.2"
  },
  "dependencies": {
    "node-js": "^1.0.0"
  }
}
|

hardhat.config.js:

require("@nomicfoundation/hardhat-toolbox")
require("@nomiclabs/hardhat-etherscan")
require("hardhat-deploy")
require("hardhat-contract-sizer")
require("dotenv").config()`

`module.exports = {
    solidity: "0.8.7",
}

New to javascript/solidity, have been on stuck this for some hours.

I thank you all in advance:).

4
  • Downgrading "chai" from 5.00 to 4.3.7 helped solve the error, i had dependencies that require ES modules and thats why i got the error.
    – Plair
    Commented Jan 7 at 22:01
  • 1
    Hi! I'm happy you found a solution, but instead of leaving it as a comment, please leave it as an answer to the question - it's more likely to help others with the same issue that way. Cheers! Commented Jan 8 at 10:48
  • will do thank you:)
    – Plair
    Commented Jan 10 at 20:08
  • i got same error. i have change config name from .js to .cjs.. and also add "type": "module", in package.json file still facing same error... please share solution if anyone have an answer..
    – Dipak B.
    Commented Jun 14 at 15:16

1 Answer 1

6

Downgrading "chai" from 5.00 to 4.3.7 helped solve the error, i had dependencies that require ES modules and thats why i got the error.

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.