#Unknown file extension ".ts"

5 messages · Page 1 of 1 (latest)

plush sigil

So I switched out the .js on all my files with .ts so I could import types.

But when I then tried running my bot using node src/main.ts, I got the following error:

TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts"

It even told me to remove the .ts file extensions from my imports, so I did that everywhere I saw a .ts in an import.

quartz ivyBOT
  • Consider reading #how-to-get-help to improve your question!
  • Explain what exactly your issue is.
  • Post the full error stack trace, not just the top part!
  • Show your code!
  • Issue solved? Press the button!
marble sapphire

You cannot directly run typescript files using nodejs. You have to compile them using tsc

plush sigil

Do I need to install tsc with pnpm then?

marble sapphire

tsc is pre-installed with the typescript package