NewSchokr 13 is here. A whole new UI, seven locations, snapshots and more. Read more →

How to run a TypeScript app on Schokr

Run TypeScript on Schokr: compile with tsc and run the JavaScript, use tsx on Node.js, or run .ts files directly with Bun.

Updated · 2 min read

Node.js cannot reliably run your TypeScript source as-is in production, so on Schokr you have three options: compile to JavaScript and run that, run it through a loader like tsx, or use the Bun template, which runs .ts files directly.

tsconfig.json:

{
  "compilerOptions": {
    "target": "ES2022",
    "module": "NodeNext",
    "moduleResolution": "NodeNext",
    "outDir": "dist",
    "rootDir": "src",
    "strict": true,
    "esModuleInterop": true
  },
  "include": ["src"]
}

package.json scripts:

{
  "scripts": {
    "build": "tsc",
    "start": "node dist/index.js"
  }
}

Build on your computer with npm run build, upload the dist folder with package.json and the lock file, and set the main file to dist/index.js in your server's Startup settings. Building locally keeps the server lean, because typescript can stay a dev dependency.

To build on the server instead, the start command becomes npm run build && npm start, and typescript must be installed there.

Option 2: tsx on Node.js

tsx runs TypeScript directly without a separate build:

{
  "dependencies": { "tsx": "^4.19.0" },
  "scripts": { "start": "tsx src/index.ts" }
}

It does not type-check; it just strips types. Startup is a little slower and memory use a little higher than compiled JavaScript, but it is simple. Keep tsx in dependencies, not devDependencies, if the server installs production dependencies only.

Recent Node.js versions can also strip types natively, but the feature has changed between versions. If you rely on it, check the Node.js docs for the version your server runs.

Option 3: Bun

On a Bun server, set the main file to src/index.ts and you are done. Bun transpiles TypeScript on the fly. See deploying a Bun HTTP server.

Which to choose

tsc buildtsxBun
Build stepYesNoNo
Type-checksYes, at buildNoNo
Runtime overheadNoneSmallNone
Best forProduction Node.js appsQuick deploys, botsNew projects

Common errors

  • Unknown file extension ".ts": Node.js is running a .ts file directly. Use one of the options above.
  • Cannot find module './utils' after compiling: with NodeNext, write imports as ./utils.js in your TypeScript source; the compiled file uses that path. See module not found.
  • Path aliases like @/lib fail at runtime: tsc does not rewrite aliases. Use relative imports, a bundler, or a tool such as tsc-alias.
  • Build killed: compiling large projects uses memory. Build locally or see memory limits.

Always type-check locally with tsc --noEmit before uploading, whichever option you use.