title: Jade files, routes folder and server/app.js is not rendering or redirecting
body: <pre><code>//routes/meal.js
  var express = require('express');
  var router = express.Router();
  var app = express();
  /* GET users listing. */
  router.get('/meal', function(req, res, next) {
      res.render('/home/noah/Desktop/gadfit/views/meal.jade');
      //res.send('respond with a resource');
  });
  
  router.post('/meal', (req, res) =&gt; {
      //res.send('POST request to the homepage');
      //res.redirect('http://google.com')
      console.send(req.query + req.body);
      res.json({ 1: 1 });
  });
  
  router.patch('/meal', (req, res) =&gt; {
      res.send(`PACTH request to / body:${req.body} params: ${req.params[0]}`);
  });
  router.trace('/meal', (req, res) =&gt; {
      res.send('SEND request to /');
  });
  app.copy('/meal', (req, res) =&gt; {
      res.send('COPY request to /');
  });
  app.lock('/meal', (req, res) =&gt; {
      res.send('LOCK request to /');
  });
  app.purge('/meal', (req, res) =&gt; {
      res.send('PURGE request to / ');
  });
  app.head('/meal', (req, res) =&gt; {
      res.send('HEAD request to /');
  });
  app.link('/meal', (req, res) =&gt; {
      res.send('LINK request request to / ');
  });
  app.delete('/meal', (req, res) =&gt; {
      res.send('DELETE request to /');
  });
  app.options('/meal', (req, res) =&gt; {
      res.send('OPTIONS request to /');
  });
  app.connect('/meal', (req, res) =&gt; {
      res.send('CONNECT request to /');
  });
  app.trace('/meal', (req, res) =&gt; {
      res.send('TRACE request to /');
  });
  
  module.exports = router;
  </code></pre>
  <pre><code>// meal.jade 
  doctype doctype html
  extends layout
  
  html(lang=&quot;en&quot;)
    head
      meta(charset=&quot;UTF-8&quot;)
      meta(http-equiv=&quot;X-UA-Compatible&quot;, content=&quot;IE=edge&quot;)
      meta(name=&quot;viewport&quot;, content=&quot;width=device-width, initial-scale=1.0&quot;)
      title Document
    body
      block content
        p 'meal plan'
  </code></pre>
  <pre><code>//app.js 
  const express = require('express');
  const path = require('path');
  const cookieParser = require('cookie-parser');
  const logger = require('morgan');
  const port = 3000;
  const bodyParser = require('body-parser');
  const router = express.Router();
  const url = require('url');
  const querystring = require('querystring');
  const http = require('http');
  const https = require('https');
  const createError = require('http-errors');
  const app = express();
  
  
  app.use(logger('dev'));
  app.use(express.json());
  app.use(express.urlencoded({ extended: true }));
  app.use(express.static(&quot;public&quot;))
  app.use(cookieParser());
  app.use(express.static(path.join(__dirname, 'public')));
  app.use(bodyParser.urlencoded({ extended: true }));
  app.use(bodyParser.json());
  
  //app.use(&quot;/&quot;, router);
  /*
  app.use(function(req, res, next) // catch 404 and forward to error handler
      {
          next(createError(404));
      });
  app.use(function(err, req, res, next) // error handler 
      {
          // set locals, only providing error in development
          res.locals.message = err.message;
          res.locals.error = req.app.get('env') === 'development' ? err : {};
  
          // render the error page
          res.status(err.status || 500);
          res.render('error');
      });
  
  app.all('/', (req, res) =&gt; {
      res.render('/home/noah/Desktop/gadfit/views/contact.jade');
  });
  app.get('/member/:name/planet/:home', (req, res) =&gt; {
      const memberDetails = {
          member: req.params.name,
          planet: req.params.home
      }
      res.render('guardian', memberDetails);
  });
  app.get('*', (req, res, next) =&gt; {
      res.status(200).send('Sorry, page not found');
      next();
  }); 
  */
  //app.set('views engine', path.join(__dirname, 'views'));
  
  app.set('views engine', 'jade');
  
  const indexRouter = require('./routes/index');
  const usersRouter = require('./routes/users');
  const contactRouter = require('./routes/contact');
  const mealRouter = require('./routes/meal');
  const gadginRouter = require('./routes/gadgin');
  const aboutRouter = require('./routes/about');
  
  app.use('/index', indexRouter);
  app.use('/users', usersRouter);
  app.use('/about', aboutRouter);
  app.use('/contact', contactRouter);
  app.use('/gadgin', gadginRouter);
  app.use('/meal', mealRouter);
  
  app.listen(port, () =&gt; {
      console.log(`Server started at port ${port}`)
  });
  
  module.exports = app;
  </code></pre>
  <p>I have a standard and basic app I want to use and make, it loads on the server.js file and I have routes being loaded into it from routes folder and each respective route/x.js folder handles particular request and responses to HTTP protocols. I am trying to divide the code for routing from the actual server app because that is called sanity. It does not load and causes a 404 error when I call a get from say 'localhost:3000/meal' when it should load the respective jade file.</p>
  <pre><code>{
    &quot;name&quot;: &quot;gadfit&quot;,
    &quot;version&quot;: &quot;0.0.0&quot;,
    &quot;private&quot;: true,
    &quot;scripts&quot;: {
      &quot;start&quot;: &quot;node ./bin/www&quot;
    },
    &quot;dependencies&quot;: {
      &quot;body-parser&quot;: &quot;^1.20.0&quot;,
      &quot;cookie-parser&quot;: &quot;~1.4.4&quot;,
      &quot;debug&quot;: &quot;~2.6.9&quot;,
      &quot;express&quot;: &quot;~4.16.1&quot;,
      &quot;http-errors&quot;: &quot;~1.6.3&quot;,
      &quot;jade&quot;: &quot;^0.29.0&quot;,
      &quot;morgan&quot;: &quot;~1.9.1&quot;,
      &quot;path&quot;: &quot;^0.12.7&quot;,
      &quot;querystring&quot;: &quot;^0.2.1&quot;,
      &quot;serve-static&quot;: &quot;^1.15.0&quot;,
      &quot;url&quot;: &quot;^0.11.0&quot;
    },
    &quot;description&quot;: &quot;Alyssa Gadson Fitness Program&quot;,
    &quot;main&quot;: &quot;app.js&quot;,
    &quot;author&quot;: &quot;Noah&quot;,
    &quot;license&quot;: &quot;ISC&quot;
  }
  
  </code></pre>
  <p>I assume this is a coding problem but it could also be an environment/npm problem.</p>