title: Deployment on heroku crashing
body: <p>I am deploying my MERN application to Heroku. The build is successful but when I open my application the web page shows application error. I checked logs but couldn't understand much from that.</p>
  <p>This is my first deployment of an MERN application, so please guide me. Thankyou.</p>
  <p><strong>These are the logs</strong></p>
  <p><a href="https://i.stack.imgur.com/qXvIs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qXvIs.png" alt="enter image description here" /></a></p>
  <p><a href="https://i.stack.imgur.com/XLPOH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XLPOH.png" alt="enter image description here" /></a></p>
  <p><strong>server.js</strong></p>
  <pre><code>const express = require('express');
  const connectDB = require('./config/database');
  const path = require('path');
  
  const app = express();
  
  const PORT = process.env.PORT || 5000;
  
  // Connect Database
  connectDB();
  
  // Init Middleware
  app.use(express.json({extended: false}));
  
  // Defining Routes
  app.use('/api/users', require('./routes/users'));
  app.use('/api/contacts', require('./routes/contacts'));
  app.use('/api/auth', require('./routes/auth'));
  
  // Serve static assets in production
  if(process.env.NODE_ENV === 'production') {
      // Set static folder
      app.use(express.static('client/build'));
  
      app.get('*', (req, res) =&gt; {
          res.sendFile(path.resolve(__dirname, 'client', 'build', 'index.html'));
      })
  }
  
  app.listen(PORT, () =&gt; {
      console.log(`Server started on port ${PORT}`);
  });
  </code></pre>
  <p><strong>server's package.json</strong></p>
  <pre><code>{
    &quot;name&quot;: &quot;contact-keeper&quot;,
    &quot;version&quot;: &quot;1.0.0&quot;,
    &quot;description&quot;: &quot;Contact Manager App&quot;,
    &quot;main&quot;: &quot;server.js&quot;,
    &quot;scripts&quot;: {
      &quot;start&quot;: &quot;node server.js&quot;,
      &quot;server&quot;: &quot;nodemon server.js&quot;,
      &quot;client&quot;: &quot;npm start --prefix client&quot;,
      &quot;clientinstall&quot;: &quot;npm install --prefix client&quot;,
      &quot;dev&quot;: &quot;concurrently \&quot;npm run server\&quot; \&quot;npm run client\&quot;&quot;,
      &quot;test&quot;: &quot;echo \&quot;Error: no test specified\&quot; &amp;&amp; exit 1&quot;,
      &quot;heroku-postbuild&quot;: &quot;NPM_CONFIG_PRODUCTION=false npm install --prefix client &amp;&amp; npm run build --prefix client&quot;
    },
    &quot;engines&quot;: {
      &quot;node&quot;: &quot;12.18.3&quot;
    },
    &quot;keywords&quot;: [],
    &quot;author&quot;: &quot;&quot;,
    &quot;license&quot;: &quot;ISC&quot;,
    &quot;dependencies&quot;: {
      &quot;bcrypt&quot;: &quot;^5.0.1&quot;,
      &quot;config&quot;: &quot;^3.3.6&quot;,
      &quot;express&quot;: &quot;^4.17.1&quot;,
      &quot;express-validator&quot;: &quot;^6.12.1&quot;,
      &quot;jsonwebtoken&quot;: &quot;^8.5.1&quot;,
      &quot;mongoose&quot;: &quot;^5.13.4&quot;
    },
    &quot;devDependencies&quot;: {
      &quot;concurrently&quot;: &quot;^6.2.0&quot;,
      &quot;nodemon&quot;: &quot;^2.0.12&quot;
    }
  }
  
  </code></pre>