For my project, I have set up mocha to test my Typescript code. The issue arises when running the command:
mocha ts/test --compilers ts:typescript-require
Every time I make a change, it fails with an error message like this:
error TS2307: Cannot find module 'mocha'.
Oddly enough, if I simply run tsc
, everything works fine (I have all the necessary type definitions and a tsconfig.json
file). I even installed typescript-require
for mocha
.
What's even more confusing is that after I run the command once, it starts working as expected. However, when I use the watch mode with mocha:
mocha -w ts/test --compilers ts:typescript-require
It initially works but then fails upon subsequent runs. It's frustrating! Does anyone have any tips on setting up a stable configuration for testing and watching Typescript code with mocha
?