Node ERR_UNKNOWN_FILE_EXTENSION ".ts" in CI - Run TypeScript Correctly
ERR_UNKNOWN_FILE_EXTENSION means you asked node to execute a .ts file directly, but the plain Node runtime has no loader registered for TypeScript.
What this error means
A CI step runs node src/index.ts and throws TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts". It works locally where a TS loader is wired up.
node
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts"
for /home/runner/work/app/app/src/index.ts
at Object.getFileProtocolModuleFormat (node:internal/modules/esm/load:101:9)Common causes
Running .ts files with plain node
Stock Node has no TypeScript loader on older versions, so it cannot determine a module format for .ts.
A missing loader registration
The tsx or ts-node loader is registered via a flag or NODE_OPTIONS locally but not in the CI command.
How to fix it
Run TypeScript with tsx
- Invoke the file through tsx, which registers a TypeScript loader.
- Use the same command locally and in CI.
GitHub Actions
- run: npx tsx src/index.tsCompile first, then run the JavaScript
- Add a tsc build step to emit .js.
- Execute the compiled output with node.
GitHub Actions
- run: npx tsc -p tsconfig.json
- run: node dist/index.jsHow to prevent it
- Standardize on one TypeScript execution path (tsx, ts-node, or compiled output) and use it identically across local dev and CI so the loader is always present.
Related guides
Node tsx/ts-node Runtime Resolution Error in CI - Fix the TypeScript LoaderFix tsx and ts-node runtime resolution errors in CI by aligning the loader, module setting, and import extens…
Node "SyntaxError: Unexpected token 'export'" in CI - Fix the Parse ErrorFix the Node.js "SyntaxError: Unexpected token export" in CI by loading the file as ESM or compiling the ESM-…
Node "Error: Cannot find module 'X'" in CI - Fix Module ResolutionFix the Node.js "Error: Cannot find module" crash in CI by correcting the path, extension, or build output th…