Reputation: 97
Im trying to load a handlebars file called login.hbs
but I keep getting an error: Error: ENOENT: no such file or directory, open '/Users/admin/Documents/tc-master/server/views/layout/default-layout.hbs'
Code and directory structure:
Upvotes: 4
Views: 7656
Reputation: 231
In the above example from the course, Max does not use any layout in the beginning and the default value for the engine initialization makes the
extname as .handlebars
defaultLayout as main-layout as the
layoutsDir as view/layouts.
we have to initialize this with blank values in the beginning as below if we don't have any layout defined yet,
app.engine(
'hbs',
expressHbs({
extname: "hbs",
defaultLayout: "",
layoutsDir: "",
})
);
Upvotes: 20