Cannot destructure property 'templateName' of 'precompile(...)' as it is undefined.

See original GitHub issue

I created a separate mail module located on src/mail/mail.module.ts MailerModule.forRoot({ transport: { host: 'localhost', port: 1025, secure: true, auth: { user: 'hi', pass: 'hi' }, }, defaults: { from: '"Admin" <admin@localhost.com>' }, template: { dir: process.cwd() + '/templates', adapter: new HandlebarsAdapter(), options: { strict: true }, }, })

my template is src/mail/templates/auth/signup-success.html.hbs

this is my service await this.mailService.sendMail({ to: userMail, subject: 'Welcome to our app', template: '/auth/signup-success.html', context: { name: 'MyName', }, })

I configure my nest-cli.json

"compilerOptions": { "assets": ["mail/templates/**/*.hbs"], "watchAssets": true }

I don’t know what to use process.cwd() / __dirname.

I don’t know what developer do here, I try 25 different combination, every-time I get this err.

I ask, how to include .hbs file that just work.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
juandavcommented, Jun 19, 2022

please, use v1.7.0

2reactions
morpheus-87commented, Apr 15, 2022

This bug is already fixed by #743 , but there is no new release with this fix 🙈

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot destructure property 'templateName' of precompile #559
Hello, I'm getting this error: {"statusCode":502,"message":"Cannot destructure property 'templateName' of 'precompile(...)' as it is undefined.
Read more >
Cannot destructure property `compile` of 'undefined' or 'null ...
The issue is with the webpack-dev-server which shouldn't be used in production, so it's generally safe to have a vulnerability in this ...
Read more >
Cannot destructure property 'templateName' of 'precompile(...)'
I get this error when I use templates. TypeError: Cannot destructure property 'templateName' of 'precompile(...)' ...
Read more >
Cannot destructure Property of Undefined Error in JS
The "Cannot destructure property of undefined" error occurs when we try to destructure a property from a value that is equal to `undefined`....
Read more >
Precompiling templates - Handlebars
If using the precompiler's normal mode, the resulting templates will be stored to the Handlebars.templates object using the relative template ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found