Use multiples DefaultLayout (express-handlebars) in Nodejs: ( Error: ENOENT: no such file or directory )

后端 未结 1 1051
梦毁少年i
梦毁少年i 2021-01-26 10:14

I ask my probleme here

But after I use the proposed solution I had this error:

Error: ENOENT: no such file or directory, open \'E:\\test\\views\\layout         


        
1条回答
  •  温柔的废话
    2021-01-26 10:45

    This is due to express-handlebars's default path resolving. Add layout: false to disable it.

    app.get('/', (req, res) =>{
        res.render('index.hbs', {layout: false});
    });
    

    Or defaultLayout: null

    app.engine(
          "hbs",
          exphbs({
            defaultLayout: null ,
          })
    

    0 讨论(0)
提交回复
热议问题