I've created an hardhat project that uses typescript. As I'm trying to run the test from intellij I'm getting:
TSError: ⨯ Unable to compile TypeScript:
test/index.ts(2,10): error TS2305: Module '"hardhat"' has no exported member 'ethers'.
If I run the test from command line it works just fine:
Here is my intellij run configuration:
On a side note - everything works just fine with a javascript hardhat project (I'm able to debug it using intellij without any problem), the problem occurs only with a typescript hardhat project.
I have tried installing mocha-typescript and @testdeck/mocha and change the intellij run configuration to run using mocha-typescript:
But then got:
× ERROR: Error: Could not load ui "mocha-typescript":
Error: Cannot find module 'C:\Users\Yogev\dev\temp\mocha-typescript'
Require stack:
- C:\NodeNpm\npm\node_modules\mocha\lib\cli\run-helpers.js
- C:\NodeNpm\npm\node_modules\mocha\lib\cli\options.js
- C:\NodeNpm\npm\node_modules\mocha\bin\mocha
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at exports.validateLegacyPlugin (C:\NodeNpm\npm\node_modules\mocha\lib\cli\run-helpers.js:234:27)
at C:\NodeNpm\npm\node_modules\mocha\lib\cli\run.js:355:9 {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\NodeNpm\\npm\\node_modules\\mocha\\lib\\cli\\run-helpers.js',
'C:\\NodeNpm\\npm\\node_modules\\mocha\\lib\\cli\\options.js',
'C:\\NodeNpm\\npm\\node_modules\\mocha\\bin\\mocha'
]
Why is that? How can I debug my tests using intellij in a typescript project?
BTW, this is the test file: