'Node.js that is not supported by Hardhat - error:0308010C:digital envelope routines::unsupported

Every time I try to use a hardhat command (i.e. npx hardhat test) in my project, I get the following error:

You are using a version of Node.js that is not supported by Hardhat, and it may work incorrectly, or not work at all.

Please, make sure you are using a supported version of Node.js.

To learn more about which versions of Node.js are supported go to https://hardhat.org/nodejs-versions


  0 passing (0ms)

An unexpected error occurred:

Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:67:19)
    at Object.createHash (node:crypto:133:10)
    at hash160 (/Users/mabeloza/abja/abja_webapp/src/node_modules/ethereum-cryptography/vendor/hdkey-without-crypto.js:249:21)
...

  opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
  library: 'digital envelope routines',
  reason: 'unsupported',
  code: 'ERR_OSSL_EVP_UNSUPPORTED'

I am using the following Hardhat dependencies in my nodeJS app and am using the nodeJS 18.1.0.

"@nomiclabs/hardhat-ethers": "^2.0.5",
"@nomiclabs/hardhat-etherscan": "^3.0.3",
"@nomiclabs/hardhat-waffle": "^2.0.3",

Which hardhat version should I use to be able to use the latest nodeJS? Or is there a specific nodeJS I need to use for hardhat?



Sources

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

Source: Stack Overflow

Solution Source