node.js - Error: Failed to lookup view "layout" in views directory -


i getting error error: failed lookup view "layout" in views directory. below source code of files folder structure.

index.ejs

<!doctype html> <html> <head>     <title>form handling</title> </head> <body>     <h1>hello world</h1> </body> </html> 

server.js

//require express var express = require('express') var app = express() var expresslayouts = require('express-ejs-layouts')  //setting view engine ejs app.set('view engine', 'ejs') app.use(expresslayouts)  //specifying router file var router = require('./routes') app.use('/', router)  //starting server on port 8004 app.listen(8004, function () {     console.log('server running @ port 8004...!'); }) 

routes.js

    //require express var express = require('express') var app = express()  //creating router object var router = express.router()  //export these routes other files module.exports = router   //routes router.get('/', function (req, res) {     res.render('index'); }) 

this formhandling folder structure:

this formhandling folder structure


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -