title: Accidentally running TypeScript code directly with `node` without `ts-node`, why does it work?
body: <p>I have set up a very simple node.js project with TypeScript. My package.json, from which you can see what packages I have installed (there is no <code>ts-node</code>), looks like this:</p>
  <pre><code>{
    &quot;name&quot;: &quot;mydemo&quot;,
    &quot;version&quot;: &quot;1.0.0&quot;,
    &quot;description&quot;: &quot;&quot;,
    &quot;main&quot;: &quot;index.js&quot;,
    &quot;scripts&quot;: {
      &quot;lint&quot;: &quot;eslint . --fix&quot;,
      &quot;test&quot;: &quot;echo \&quot;Error: no test specified\&quot; &amp;&amp; exit 1&quot;,
    },
    &quot;keywords&quot;: [],
    &quot;author&quot;: &quot;&quot;,
    &quot;license&quot;: &quot;ISC&quot;,
    &quot;devDependencies&quot;: {
      &quot;@types/node-fetch&quot;: &quot;^2.6.1&quot;,
      &quot;@typescript-eslint/eslint-plugin&quot;: &quot;^5.23.0&quot;,
      &quot;@typescript-eslint/parser&quot;: &quot;^5.23.0&quot;,
      &quot;eslint&quot;: &quot;^8.15.0&quot;,
      &quot;node-fetch&quot;: &quot;^3.2.4&quot;,
      &quot;ts-node&quot;: &quot;^10.7.0&quot;,
      &quot;typescript&quot;: &quot;^4.6.4&quot;
    }
  }
  
  </code></pre>
  <p>Project structure:</p>
  <p><a href="https://i.stack.imgur.com/er8Ms.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/er8Ms.png" alt="enter image description here" /></a></p>
  <p>The <code>src/main.ts</code>:</p>
  <pre><code>const sayHi = () =&gt; {
      console.log('HI!12345');
  }
  
  sayHi();
  </code></pre>
  <p>My <code>tsconfig.json</code>:</p>
  <pre><code>{
      &quot;compilerOptions&quot;: {
          &quot;target&quot;: &quot;es2016&quot;,
          &quot;module&quot;: &quot;commonjs&quot;,
          &quot;outDir&quot;: &quot;dist&quot;,
          &quot;sourceMap&quot;:true,
          &quot;esModuleInterop&quot;: true, 
          &quot;forceConsistentCasingInFileNames&quot;: true,
          &quot;strict&quot;: true,
          &quot;skipLibCheck&quot;: true 
      }
  }
  </code></pre>
  <p>With the above setup, I can run <code>node src/main.ts</code> on terminal. Whenever I update code in <code>main.ts</code> I directly run <code>node src/main.ts</code> also shows the result with latest code.</p>
  <p>I could have installed <code>ts-node</code>, I tried and it works as well. But I wonder why without <code>ts-node</code> my setup works just fine. I mean I can already run TypeScript code by <code>node</code> command without the need to compile to and run JS.</p>
  <p>Could someone please explain to me? Seems <code>ts-node</code> is not needed at all.</p>