How do I compile TypeScript for Node?

Compiling for Node is significantly easier than compiling for the web because you don't need to bundle all your code into one file that you can deliver to the front end. This means you can skip much of the headache:

All this means that you don't need a bundler for the backend. All you need to do is compile your TypeScript files into JavaScript. tsc will work just fine for this. All you need to decide is whether you want to compile your code into ESM modules or Common JS modules. I'd recommend ESM. Read this to understand the difference.

Examples using ESM and CommonJS.

If you're compiling your TypeScript code to ES modules, you'll need to set "type":"module" in package.json to tell Node to treat this as ESM instead of CommonJS. You also need to set module to ESNext in your tsconfig.json file.

{
  "compilerOptions": {
    "module": "ESNext",
    "target": "NodeNext",
    "moduleResolution": "nodenext",
    "outDir": "dist",
    "strict": true
  }
}

Express

Here's a basic example of an express server