We are always using nodejs and we write code using vanilla JavaScript (.js extension). It's working fine, but currently we decided to create nodejs app using typescript. Unfortunately, we encounter many errors in building it (ts -> js). It is require .js code to run in the server? or just upload typescript files then run it in server using ts-node?
Thanks for your feedback.
Unfortunately, we encounter many errors in building it (ts -> js).
If they're errors in the code (TypeScript-related or otherwise), you need to resolve those before trying to use it in production.
It is require .js code to run in the server?
Node.js is a JavaScript runtime, it doesn't understand TypeScript.
You can:
ts-node or similar to compile it just-in-time; orNote that when using one of the just-in-time options, it's really important to ensure that the code compiles cleanly by compiling it during development and staging. Your production environment shouldn't be the first place a TypeScript compilation error shows up.