title: Error: Failed to lookup view "index" in views directory "public"
body: <p>I have a simple web app and when I deploy it freshly or execute it locally it works fine. However, when I kill the pm2 process and start it again with </p>
  
  <pre><code>sudo pm2 start /var/www/thewthr.app/index.js --watch -l /var/log/pm2/thewthr.app.log
  </code></pre>
  
  <p>it results in:</p>
  
  <pre><code>Error: Failed to lookup view "index" in views directory "public"
      at Function.render (/var/www/thewthr.app/node_modules/express/lib/application.js:580:17)
      at ServerResponse.render (/var/www/thewthr.app/node_modules/express/lib/response.js:1012:7)
      at /var/www/thewthr.app/index.js:35:9
      at Layer.handle [as handle_request] (/var/www/thewthr.app/node_modules/express/lib/router/layer.js:95:5)
      at next (/var/www/thewthr.app/node_modules/express/lib/router/route.js:137:13)
      at Route.dispatch (/var/www/thewthr.app/node_modules/express/lib/router/route.js:112:3)
      at Layer.handle [as handle_request] (/var/www/thewthr.app/node_modules/express/lib/router/layer.js:95:5)
      at /var/www/thewthr.app/node_modules/express/lib/router/index.js:281:22
      at Function.process_params (/var/www/thewthr.app/node_modules/express/lib/router/index.js:335:12)
      at next (/var/www/thewthr.app/node_modules/express/lib/router/index.js:275:10)
  </code></pre>
  
  <p>This is my code:</p>
  
  <pre><code>const express = require('express');
  const path = require('path');
  
  require('dotenv').config({path: path.join(__dirname, '.env')});
  
  const app = express();
  const server = require('http').Server(app);
  
  // start server
  server.listen(process.env.PORT, () =&gt; console.log(`Express running → PORT ${server.address().port}`));
  
  // start rendering engine
  app.set('view engine', 'pug');
  app.set('views', 'public');
  
  // define express props
  app.use(express.static('public'));
  app.use(express.urlencoded({extended: true}));
  app.use(express.json());
  
  // render view
  app.get('/', (req, res) =&gt; {
      res.render('index', {
          title: `weather ☀`
      });
  });
  </code></pre>