It is often assumed that a project can run without compiling, especially in development mode. However, this assumption is not entirely accurate.
During development, whether using Nest, ts-node, or deno, the TypeScript code is actually transpiled into JavaScript behind the scenes:
[ts-node] JIT transforms TypeScript into JavaScript, allowing direct execution on Node.js without precompiling.
Read more about ts-node here
Deno, at a high level, converts TypeScript (as well as TSX and JSX) into JavaScript. Learn more from Deno docs
Although specific information was not found in the Nest Docs, the presence of the typescript
package as a direct dependency of theNest CLI suggests that it is utilized for compilation purposes not just in development but also within the CLI itself before executing the project.
So, to address the initial question: Running a project in production with ts-node is indeed possible based on past experiences.
However, it may not be the best practice. Due to its JIT compilation nature, which trims out unnecessary components during execution, performance might be compromised. While efficient for development purposes, using ts-node-dev
with its watch feature, avoiding full project recompilation, switching to JavaScript over TypeScript for production is recommended though not mandatory.