Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

express-handlebars cant find dir or file

okey so im trying to get handlebars to workand so ive been following this youtube guide: https://www.youtube.com/watch?v=SfQFoMOd_ng

and my problem is that the code on row 15 gets an error:

Error: ENOENT: no such file or directory, open 'C:\Users\9826skma\Desktop\Lol stats\playground\test handlebars\views\layouts\main.handlebars'

server.js file

ive used

npm i express --save, npm i express-handlebars --save in powershell

like image 840
maxilaxen Avatar asked May 24 '18 13:05

maxilaxen


2 Answers

You can also add defaultLayout: null. So for example ...

app.engine('.hbs', exphbs({
    extname: '.hbs',
    defaultLayout: null
}));
like image 141
athammer Avatar answered Nov 05 '22 05:11

athammer


Your folder is called layout, but the code is looking for layouts.

like image 2
Niklas Wenzel Avatar answered Nov 05 '22 05:11

Niklas Wenzel