hello! looks like i have stuck here, i tried to look for solutions but they showed me the same code i had already written and it doesn’t work. maybe i should some specific older version of express or pug or something?
here is my app https://goofy-risk.glitch.me and another one where i didn’t update dependencies but still get the same mistake https://faint-pig.glitch.me
it gives me the following mistake “Failed to lookup view “/appviews/pug/index.pug” in views directory “/app/views””, apparently it’s a problem with routing but even if i write res.render('/pug/index.pug', {title: 'Hello', message: 'Please login'});
i get the following “Failed to lookup view “/pug/index.pug” in views directory “/app/views”” mistake
here is my code
'use strict';
const express = require('express');
const bodyParser = require('body-parser');
const fccTesting = require('./freeCodeCamp/fcctesting.js');
const pug = require('pug');
const app = express();
fccTesting(app); //For FCC testing purposes
app.use('/public', express.static(process.cwd() + '/public'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.set('view engine', 'pug');
app.route('/')
.get((req, res) => {
res.render(process.cwd() + 'views/pug/index.pug', {title: 'Hello', message: 'Please login'});
});
app.listen(process.env.PORT || 3000, () => {
console.log("Listening on port " + process.env.PORT);
});
faint-pig’s original dependencies
{
"//1": "describes your app and its dependencies",
"//2": "https://docs.npmjs.com/files/package.json",
"//3": "updating this file will download and update your packages",
"name": "FCC-Advanced-Node-and-Express",
"author": "http://github.com/JosephLivengood",
"version": "0.0.1",
"description": "What am I about?",
"main": "server.js",
"scripts": {
"start": "node server.js"
},
"dependencies": {
"express": "^4.14.1",
"cors": "^2.8.1",
"body-parser": "^1.16.0",
"mongodb": "^2.2.22",
"helmet": "^3.4.0",
"pug": "^0.1.0"
},
"engines": {
"node": "4.4.3"
},
"repository": {
"type": "git",
"url": "https://hyperdev.com/#!/project/welcome-project"
},
"keywords": [
"node",
"hyperdev",
"express"
],
"license": "MIT"
}