title: TypeError: express.Router is not a function in Node.js
body: <p>when I tried to run my app by npm  start the I got the error:</p>
  <pre><code>export const router = express.Router();
  ^
  
  TypeError: express.Router is not a function
  at file:///C:/Users/hassa/notes/routes/index.mjs:4:31
  </code></pre>
  <p>The code of my index.mjs file is:</p>
  <pre><code>import * as express from &quot;express&quot;;
  
  import { NotesStore as notes } from &quot;../app.mjs&quot;;
  
  export const router = express.Router();
   /* GET home page. */
  router.get(&quot;/&quot;, async (req, res, next) =&gt; {
   try {
     const keylist = await notes.keylist();
    // console.log(`keylist ${util.inspect(keylist)}`);
    const keyPromises = keylist.map((key) =&gt; {
    return notes.read(key);
  });
  const notelist = await Promise.all(keyPromises);
  // console.log(util.inspect(notelist));
  res.render(&quot;index&quot;, { title: &quot;Notes&quot;, notelist: notelist });
  } catch (err) {
    next(err);
  }
  });
  </code></pre>
  <p>I have already seen other questions with similar topic on stackoverflow but I did not get any solution. If anybody knows how to solve it then please let me know. Thanks.</p>