Monday 28 September 2020

Error: Handlebars "main" Layout Not Found in Heroku

I'm trying to upload an app to Heroku which contains the handlebars module, and works completely fine on my local server. However, whenever I try to load it on Heroku, I get the following message in logs:"Error: ENOENT: no such file or directory, open '/app/views/layouts/main.handlebars"My file structure is as follows (For some reason reddit keeps removing my indentations below, so I specified in parentheses the folder to which each file belongs) :|---src|-------- app.js(inside of src)|-views|------- layouts (folder inside of views)|--------------- main.handlebars (inside of layouts folder)|---------home.handlebarss (inside of views folder and parallel/sibling with layouts folder)app.set("views", path.join(__dirname,"../","views"));app.engine('handlebars', exphbs({ defaultLayout:"main",layoutsDir:path.join(__dirname,"../views/layouts/")}))app.set('view engine', 'handlebars');app.get('', (req,res) => { res.render('home', {biggerObject})});​I will greatly appreciate any help with this. Thanks in advance!

Submitted September 29, 2020 at 03:54AM by epistemicmind

No comments:

Post a Comment