2 years ago
Hi, I was running my Typescript Discord bot with the same configuration since Feb 2024 with no issues. My bot currently works fine when I run it locally via yarn start. I recently redeployed and am now hitting the below error after running yarn start and such my deployments crash.
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /app/src/Bot.ts
at new NodeError (node:internal/errors:405:5)
at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:136:11)
at defaultGetFormat (node:internal/modules/esm/get_format:182:36)
at defaultLoad (node:internal/modules/esm/load:101:20)
at nextLoad (node:internal/modules/esm/hooks:864:28)
at load (/app/node_modules/ts-node/dist/child/child-loader.js:19:122)
at nextLoad (node:internal/modules/esm/hooks:864:28)
at Hooks.load (node:internal/modules/esm/hooks:447:26)
at MessagePort.handleMessage (node:internal/modules/esm/worker:196:24)
at [nodejs.internal.kHybridDispatch] (node:internal/event_target:786:20) {
code: 'ERR_UNKNOWN_FILE_EXTENSION'
}
error Command failed with exit code 1.
ⓘ Deployment information is only viewable by project members and Railway employees.
1 Replies
2 years ago
Instead of ts-node I would recommend transpiling with tsc in a build script and then running the resulting js file with node in your start script.