title: Problem in rendering ejs template with Express
body: <p>I am using Node.js together with Express and EJS.</p>
  <p>Below is my code:</p>
  <pre><code>var express = require('express');
  var path = require('path');
  var bodyParser = require('body-parser');
  
  var app = express();
  var urlencodedParser = bodyParser.urlencoded({ extended: false });
  var publicPath = path.resolve(__dirname, 'public');
  app.use(express.static(publicPath));
  //app.set('views', __dirname + '/views');
  app.set('view engine', 'ejs');
  
  app.get('/form_get.html', (req, res) =&gt; {
      res.sendFile(__dirname + &quot;/&quot; + &quot;form_get.html&quot;)
  })
  
  app.get('/process_get', (req, res) =&gt; {
  
      console.log(req.query.first_name);
      res.render(path.join(__dirname+'/views/thankyou.ejs'), { name: req.query.first_name});
      
  })
  
  var server = app.listen(3000, () =&gt; {
      
      var host = server.address().address;
      var port = server.address().port;
      console.log(`Example app listening at ${host}:${port}`);
  })
  </code></pre>
  <p>My folder structure is below:</p>
  <ul>
  <li>mysql (folder)
  <ul>
  <li>node_modules (folder)</li>
  </ul>
  <ul>
  <li>app4.js (file)</li>
  <li>package.json (file)</li>
  </ul>
  <ul>
  <li>public (folder, it contains form_get.html)</li>
  <li>views (folder, it contains thankyou.ejs)</li>
  </ul>
  </li>
  </ul>
  <p>The problem is the failing to look up <code>thankyou.ejs</code> into the views folder.</p>
  <p>I get the following error message:</p>
  <blockquote>
  <p>Error: Failed to lookup view &quot;thankyou.ejs&quot; in views directory
  &quot;.../mysql/views&quot;</p>
  </blockquote>
  <p>What can be the problem?</p>