Closed utterances-bot closed 3 years ago
I am getting an exception : "Cannot destructure property 'templateName' of 'precompile(...)' as it is undefined. Any idea what to do? Only thing I've found on Google after hours of looking is to try and add "./" before the template name in mail.module.ts
The same error: "Cannot destructure property 'templateName' of 'precompile(...)' as it is undefined So frustrating since the error message doesn't help
Do you have a repo to reproduce this error? Does this error occure in this example https://github.com/notiz-dev/nestjs-mailer for you as well?
I found this issue https://github.com/nest-modules/mailer/issues/570, are you using @nestjs-modules/mailer@1.6.0
? Try out version 1.5.1
until the issue is fixed for the new version.
@keithhuels as you mentiond adding ./
before the template name is curretly the workaround for the 1.6.0
version https://github.com/nest-modules/mailer/issues/550#issuecomment-822249747
There is a comma "," missing in the compiler options. (In the article) Thanks for the article! :)
"compilerOptions": {
"assets": ["mail/templates/**/*"] // 👈 missing comma
"watchAssets": true
}
Yes, it works now that I put "./" in front of the specific template I am using in the mail service.
Another quick note, you have a "USER_FROM" in the .env file but it's not being used in the service. I believe it should be:
from: "No Reply" <${config.get('MAIL_FROM')}>
,
Thanks @parideis and @keithhuels for spotting, I updated the article!
if you're using EJS, make sure you set the strict mode to false in the config, else you'll always get undefined variable in ejs template or use locals variable : <%= user %> becomes <%= locals.user %>
Try this in your mailservices.ts template: './templates/confirmation' Refer the location of the template you want to send.
First off, great tutorial! I followed it start to finish with no hiccups. Have you found a way to include template styling other than inlining them (partials, linking to static assets, etc.)?
Hi, first of, great job with the blog post, following the steps has been really easy and everything works as expected!
I do have one question though: Is there a way to separate out styling files (.css) or do I have to define styling in the handlebars files? I tried extracting the styling in a style.css file in the same directory as the handlebars file, but it seem like it isn't resolved properly. I have checked, that the .css file is also transported into the dist folder.
Hi, thanks for that tutorial !
I'm having some trouble with the template part of things though.
first of template seems to not go where they would be supposed to in the dist folder. it comes out as :
Dist |-mail/templates |-src |-mail/mail.module.js
Wich is kinda strange, and not consistent with what you've got on the tutorial. Because of that i've got the "Cannot destructure property 'templateName' of 'precompile(...)' as it is undefined." error but adding the "./" to template doesn't change a thing.
I've tried tinkering around with no luck :/
I had a problem where templates where copied to dist
folder instead of dist/src
.
I updated nest-cli.json
to make it work:
{
"collection": "@nestjs/schematics",
"sourceRoot": "src",
"compilerOptions": {
"assets": [{ "include": "mail/templates/**/*", "outDir": "dist/src" }],
"watchAssets": true
}
}
outDir
tells compiler to copy templates to src
folder, it works now.
I had a problem where templates where copied to
dist
folder instead ofdist/src
. I updatednest-cli.json
to make it work:{ "collection": "@nestjs/schematics", "sourceRoot": "src", "compilerOptions": { "assets": [{ "include": "mail/templates/**/*", "outDir": "dist/src" }], "watchAssets": true } }
outDir
tells compiler to copy templates tosrc
folder, it works now.
Thanks a lot !
thanks for the amazing tutorial. when installing i get see 8 high severity vulnerabilities:
css-what <5.0.1
Severity: high
Denial of Service - https://npmjs.com/advisories/1754
Thanks for the article. As you suggested above, I had to add ./ to the template name. Outside of that everything worked perfect!
How to build such a blog theme,thinks!
Send Emails with NestJS
Create Email Templates and send them with nodemailer from your Nest application
https://notiz.dev/blog/send-emails-with-nestjs