enter image description hereI am trying to run an ejs file and gets error Error: Could not find the include file "partials/head".
i have checked most of the articles from stackoverflow and github however not able to resolve it ...
Error: Could not find the include file "partials/head" at getIncludePath (C:\Users\Junia\Desktop\node\node_modules\ejs\lib\ejs.js:162:13) enter code here at includeSource (C:\Users\Junia\Desktop\node\node_modules\ejs\lib\ejs.js:306:17) at C:\Users\Junia\Desktop\node\node_modules\ejs\lib\ejs.js:672:26 at Array.forEach () at Template.generateSource (C:\Users\Junia\Desktop\node\node_modules\ejs\lib\ejs.js:648:15) at Template.compile (C:\Users\Junia\Desktop\node\node_modules\ejs\lib\ejs.js:552:12) at Object.compile (C:\Users\Junia\Desktop\node\node_modules\ejs\lib\ejs.js:388:16) at handleCache (C:\Users\Junia\Desktop\node\node_modules\ejs\lib\ejs.js:212:18) at tryHandleCache (C:\Users\Junia\Desktop\node\node_modules\ejs\lib\ejs.js:251:16) at View.exports.renderFile [as engine] (C:\Users\Junia\Desktop\node\node_modules\ejs\lib\ejs.js:480:10)
var express=require('express');
var app=express();
var router=express.Router();
var mysql=require('mysql');
var cookieParser=require('cookie-parser');
var session=require('express-session');
app.use(session({
secret: 'secret',
resave: true,
saveUninitialized: true
//cookie : { maxAge : 60000 }
}));
var path=require('path');
var bodyParser=require('body-parser');
app.use(express.static('/'));
//Serves all the request which includes /images in the url from Images folder
app.use('/images', express.static(__dirname + '/images'));
app.use('/bs4', express.static(__dirname + '/bs4'));
app.use(cookieParser());
const ejsLint = require('ejs-lint');
var con=mysql.createConnection(
{
host:'localhost',
user:'root',
password:'',
database:'shintoj'
});
var path = require('path');
app.use('/',router);
app.use('/',express.static(__dirname + '/'));
app.set('views', path.join(__dirname, 'views/pages'));
app.set('view engine', 'ejs');// use res.render to load up an ejs view file
// index page
router.get('/', function(req, res) {
//res.send('Welcome');
res.render('index');
});
app.listen(8080);
console.log('8080 is the magic port');
console.log(app.get('views'));
index.ejs file
<head>
<%- include partials/head %>
</head>
<body class="container">
<header>
<% include partials/header.ejs %>
</header>
<div class="jumbotron">
<h2>Welcome to our services .</h2>
<p>Hello</p>
</div>
<footer>
<% include partials/footer.ejs %>
</footer>
expected actual result is .. when i run node server.js , it should display the index.ejs file