title: Node.js express.Router ERR_MODULE_NOT_FOUND when import the new routes
body: <p>I am experiencing a weird error. I was just creating a new folder to separate my routes.</p>
  <p>Inside I created the routes using the <code>express.Router</code> API and I exported the router itself.</p>
  <p>Here is how the code looks like inside <code>post-routes.ts</code>:</p>
  <pre><code>import express from 'express';
  
  const router = express.Router();
  
  router.get( '/', ( req, res ) =&gt;
  {
      res.send( 'This is working' );
  } );
  
  export default router;
  </code></pre>
  <p>Ok. All I have to do now is to import it inside my <code>index.ts</code> and create a root route for my <code>post-routes.ts</code> file.</p>
  <p>Please tell me if you see something wrong in my approach.</p>
  <p><code>index.ts</code> file:</p>
  <pre><code>import express from 'express';
  import cors from 'cors';
  import postRouter from './routes/post-routes';
  
  const PORT = process.env.PORT || 5000;
  
  app.use( '/posts', postRouter );
  
  
  app.use( express.json( { limit: '30mb' } ) );
  app.use( express.urlencoded( { limit: '30mb', extended: true } ) );
  app.use( cors() );
  
  app.listen( PORT, () =&gt; console.log( `listening at ${ PORT }` ) );
  </code></pre>
  <p>Good. Now to offer as much information as I possibly can, I will insert the following:</p>
  <ol>
  <li>File structure inside my project:</li>
  </ol>
  <p><a href="https://i.stack.imgur.com/DBc2O.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DBc2O.png" alt="FILE STRUCTURE" /></a></p>
  <ol start="2">
  <li><code>package.json</code> file configuration:</li>
  </ol>
  <p><a href="https://i.stack.imgur.com/8n2kF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8n2kF.png" alt="PACKAGE.JSON FILE" /></a></p>
  <p>As you can see, I am using the <code>&quot;type&quot;: &quot;module&quot;</code> to be able to use import inside my node application. As for the typescript, I am getting no compiling errors, so <code>index.ts</code> sees the <code>post-routes.ts</code> file so I would expect that <code>index.js</code> would see <code>post-routes.js</code> file as well. But the server throws the error below. How can this be?</p>
  <p><code>Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'E:\Github\hospytal-fasion\server\dist\routes\post-routes' imported from E:\Github\hospytal-fasion\server\dist\index.js</code></p>