standard tsconfig for node projects



~1 min read


129 words

The following is a simple tsconfig that I’ve found helpful when writing simple node applications.

  "compilerOptions": {
    "outDir": "./dist",
    "target": "es5",
    "lib": ["esnext"],
    "baseUrl": ".",
    "moduleResolution": "node",
    "esModuleInterop": true
  "include": ["./src/**/*"],
  "exclude": ["**/*.test.*"]

I’ve found myself copying and pasting it between projects, so sharing it here as a resource for the future.

Once this is in place, you can compile and run your Typescript applications from the command line like so:

$ tsc -b .
$ node dist/index.js

The . is not strictly necessary, but demonstrates that I’m compiling the current working directory. The compiled application is saved to the dist/ directory, so I can now invoke it with Node.

And just like that, I’m running a Node application written in Typescript!

Hi there and thanks for reading! My name's Stephen. I live in Chicago with my wife, Kate, and dog, Finn. Want more? See about and get in touch!