Error finding directory . handlebars

Asked

Viewed 166 times

1

I have the following folder and file structure in my Node project:

inserir a descrição da imagem aqui

And the following configuration of email templates:

configureTemplates() {
    const viewPath = resolve(__dirname, '..', 'app', 'views', 'emails');

    this.transporter.use('compile', nodemailerhbs({
      viewEngine: exphbs.create({
        layoutsDir: resolve(viewPath, 'layouts'),
        partialsDir: resolve(viewPath, 'partials'),
        defaultLayout: 'default',
        extName: '.hbs',
      }),
      viewPath,
      extName: '.hbs',
    }));
  }

When I run the method, the following error is displayed to me:

inserir a descrição da imagem aqui

What is wrong ?

1 answer

1


I found the problem. The property extname from within the method create, is written all lower case. Only property extName of the method use is written in capital letters N.

configureTemplates() {
    const viewPath = resolve(__dirname, '..', 'app', 'views', 'emails');

    this.transporter.use('compile', nodemailerhbs({
      viewEngine: exphbs.create({
        layoutsDir: resolve(viewPath, 'layouts'),
        partialsDir: resolve(viewPath, 'partials'),
        defaultLayout: 'default',
        extname: '.hbs',
      }),
      viewPath,
      extName: '.hbs',
    }));
  }

Browser other questions tagged

You are not signed in. Login or sign up in order to post.