title: How to fix Node JS error cannot find module 'express' on heroku?
body: <p>I have the below node js code that it works perfectly fine locally but when I deploy it to heroku I get an error says &quot;Error: Cannot find module 'express'
  internal/modules/cjs/loader.js:968 throw error&quot;</p>
  <pre><code>    const port = process.env.PORT || 5000;
      const express = require('express');
      require('dotenv').config();
      const app = express();
     
      app.set('view-engine','ejs');
      app.use(express.urlencoded({extended:false}));
      app.get('/',(req,res) =&gt; {
      res.render('index.ejs');
     });
     app.listen(port, ()=&gt;{console.log(`Listening on http://localhost:${port}`)});
  </code></pre>
  <p>package.json</p>
  <pre><code>{
    &quot;name&quot;: &quot;mtNodeApp&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;start&quot;: &quot;node index.js&quot;,
      &quot;devStart&quot;: &quot;nodemon index.js&quot;
    },
    &quot;author&quot;: &quot;&quot;,
    &quot;license&quot;: &quot;ISC&quot;,
    &quot;devDependencies&quot;: {
      &quot;bcrypt&quot;: &quot;^5.0.0&quot;,
      &quot;body-parser&quot;: &quot;^1.19.0&quot;,
      &quot;dotenv&quot;: &quot;^8.2.0&quot;,
      &quot;ejs&quot;: &quot;^3.1.3&quot;,
      &quot;express&quot;: &quot;^4.17.1&quot;,
      &quot;mongoose&quot;: &quot;^5.10.0&quot;,
      &quot;nodemon&quot;: &quot;^2.0.4&quot;,
      &quot;request&quot;: &quot;^2.88.2&quot;
    }
  }
  </code></pre>
  <p>Any thoughts, I am not sure what I am missing?!</p>
  <p>Thank you</p>