#TIL 7 - Use tsconfig.json for ts-node | ProductsWay

#TIL 7 - Use tsconfig.json for ts-node

Oct 8, 2020 · Dung Huynh

What

Add a ts-node section to your existing tsconfig.json with runtime-specific compiler overrides.

Why

Your build may target ES modules while ts-node needs CommonJS to execute scripts with require(). Putting overrides in tsconfig.json keeps one config file instead of passing flags on every ts-node invocation.

How

{
  "ts-node": {
    "compilerOptions": {
      "module": "commonjs"
    }
  },
  "compilerOptions": {
    // Your project config
  }
}