Reputation: 41
I'm using express framework,
//Handlebars Middleware
app.engine('handlebars', exphbs({
defaultLayout: 'main'
}));
app.set('views', path.join(__dirname, './views'));
app.set('view engine', 'handlebars');
My directory looks like:
and it gives the below error whenever I try to run.
Error: ENOENT: no such file or directory,
open 'C:\Users\Sourav\forum\bin\views\layouts\main.handlebars'
Any help is appreciated. It's my first question so, every suggestion regarding question clarity is very much appreciated.
Thanks
Upvotes: 0
Views: 2941
Reputation: 46
__dirname in this case is pointing inside bin folder, instead of './views' use '../views'
Upvotes: 1