Is it possible to override which tsconfig.json
ts-node uses when called from mocha?
My main tsconfig.json
contains \"module\": \"es20
While there doesn't seem to be a unified linux/windows command line phrasing that works, you can set the compiler-options
from the command line. In my case, much like the OP, I have a tsconfig.json
with a module: esnext
. I was able to override on the command line:
Ran on Windows, w/ts-node
installed globally, but in different shell types:
bash/mingw64:
ts-node --compiler-options={"module":"commonJS"} xxx.ts
cmd:
ts-node --compiler-options={\"module\":\"commonJS\"} xxx.ts
In package.json - scripts section:
"test": "TS_NODE_PROJECT=src mocha"
picks up my tsconfig.json in the src directory of my project, overriding the default tsconfig.json.
OP can achieve same by using test instead of src