I am new to Typescript and came across ts-node and tsc, that is, if we install ts-node, is tsc included by default inside ts-node since as far as I know, ts-node understands Typescript and runs it directly
Asked
Active
Viewed 6,654 times
1 Answers
10
tsc
is the TypeScript compiler, which is completely separate from ts-node
.
ts-node
is a wrapper for Node.js's node
executable that installs a TypeScript-enabled module loader that compiles TypeScript on the fly as needed. From its npm
page:
TypeScript Node works by registering the TypeScript compiler for
.tsx?
and.jsx?
(whenallowJs
== true) extensions. When node.js has an extension registered (via require.extensions), it will use the extension internally for module resolution.
ts-node
uses tsc
by default, but can use other compilers if you specify the --compiler
option.

T.J. Crowder
- 1,031,962
- 187
- 1,923
- 1,875
-
1so, ts-node kinda has its own compiler and we can use either ts-node or tsc, if so, which is used when? for example for development and production. Thank you – Sukich Nov 20 '19 at 12:56
-
2@Sukich - No, `ts-node` is not a compiler. It *uses* a compiler. `ts-node` is useful for when you want to have a tool (`ts-node`) handle compiling your Node.js-based TypeScript for you on-the-fly. `tsc` is useful any other time you want to compile TypeScript to JavaScript -- because you don't want to do that at runtime on Node.js, or because you're not using Node.js at all (compiling to JavaScript for another environment, such as a web browser). – T.J. Crowder Nov 20 '19 at 12:57