npx hardhat test (error) #7945
Replies: 3 comments
-
|
Hey @solidcodes, we would need some more details to help, are you able to push a minimal reproducible example: https://stackoverflow.com/help/minimal-reproducible-example ? |
Beta Was this translation helpful? Give feedback.
-
|
Hi! This error is typically caused by corrupted dependencies or version conflicts in your Hardhat project. Solution 1: Clean Install (Most Common Fix) ✅Try this first - it solves 90% of these errors: # Delete node_modules and package-lock.json
rm -rf node_modules package-lock.json
# Clear npm cache
npm cache clean --force
# Reinstall dependencies
npm installIf you're on Windows (which I see you are), use: rmdir /s /q node_modules
del package-lock.json
npm cache clean --force
npm installThen try running your test again: npx hardhat testSolution 2: Check Node.js VersionHardhat v3 requires Node.js 18 or higher. Check your version: node --versionIf you're on Node.js 16 or lower, upgrade to Node.js 18 or 20 from: https://nodejs.org/ Solution 3: Update Hardhat and PluginsMake sure all your packages are compatible: npm install --save-dev hardhat@latest
npm install --save-dev @nomicfoundation/hardhat-toolbox@latest
npm install --save-dev @nomicfoundation/hardhat-verify@latestThen reinstall: rm -rf node_modules package-lock.json
npm installSolution 4: Use Legacy Peer DependenciesIf the above doesn't work, try: npm install --legacy-peer-depsCheck Your hardhat.config.jsMake sure you're importing the verify plugin correctly: require("@nomicfoundation/hardhat-toolbox");
require("@nomicfoundation/hardhat-verify");
module.exports = {
solidity: "0.8.28",
// ... rest of your config
};Most Likely Fix:Based on your error, I'd recommend Solution 1 (clean reinstall) first. This usually resolves the "Class extends value undefined" error. Let me know if this works! If you still get the error, share your |
Beta Was this translation helpful? Give feedback.
-
|
This stack trace starts inside
First, print the versions you actually have: npm ls hardhat @nomicfoundation/hardhat-verify @nomicfoundation/hardhat-ethers @nomicfoundation/hardhat-toolboxThen do one quick check:
If tests start working, the problem is the plugin version mix, not your test code. Right now the current Hardhat 3 line is:
If your project mixes Hardhat 3 with older plugin versions, this kind of error is expected. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello guys, when I run a hardha ttest it shows these error messages below, how to fix?
An unexpected error occurred:
TypeError: Class extends value undefined is not a constructor or null
at Object. (C:\Users\solid\hardhat-tutorial\node_modules@nomicfoundation\hardhat-verify\src\internal\errors.ts:9:41)
at Module._compile (node:internal/modules/cjs/loader:1706:14)
at Object..js (node:internal/modules/cjs/loader:1839:10)
at Module.load (node:internal/modules/cjs/loader:1441:32)
at Function._load (node:internal/modules/cjs/loader:1263:12)
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:237:24)
at Module.require (node:internal/modules/cjs/loader:1463:12)
at require (node:internal/modules/helpers:147:16)
at Object. (C:\Users\solid\hardhat-tutorial\node_modules@nomicfoundation\hardhat-verify\src\index.ts:27:1)
If you think this is a bug in Hardhat, please report it here: https://hardhat.org/report-bug
Beta Was this translation helpful? Give feedback.
All reactions