Closed ProductOfAmerica closed 5 years ago
@ProductOfAmerica can you please share the content of the files html.pug
and subject.pug
? The reason is because they are rendering as being blank. If you want to keep them private you could email them to me, niftylettuce@gmail.com. Please do this ASAP so I can make sure that this is not a core bug from the last version of this package published on NPM.
@niftylettuce email sent
@ProductOfAmerica what version of email-templates
are you on by the way?
@ProductOfAmerica I think you need to specify a root option because you may not be running node from the root folder of where the app is.
const root = path.join(__dirname, 'emails');
const email = new Email({
views: { root }
});
Right now it uses path.resolve('emails')
to find the directory.
Perhaps we can fix this so it recursively finds the root directory of the project using pkg-dir and then use that directory + emails.
@niftylettuce Unfortunately that didn't work. However, the solution was this:
const email = new Email({
views: { root: __dirname }
});
I am having the same issue, I can resolve the path but appear to get the same error.
Error: No content was passed for subject, html, text, nor attachments message props.
I have logged the props and they get to the function just fine, it seems there is an issue resolving the templates.
Add babel --copy-files
option to build command fixed the issue for me.
Detail: https://stackoverflow.com/a/35033177
@bkdev98 yep, I saw somewhere in the past. Thanks for your answer.
Hi all, I'm still running into this issue - anyone has a solution?
@Carrein have you tried debugging? see https://github.com/niftylettuce/email-templates#debugging
@niftylettuce Thanks I was using uppercases (which worked on a mac since its case insensitive but failed on linux).
I used the below command to debug to find out the reason.
DEBUG=email-templates node index.js
It points out that it has no such file or directory. And that dir doesn't include emails
in the path.
templateExists { [Error: ENOENT: no such file or directory, stat '~~~/research/send-email/mars/subject.pug']
So, I removed emails
like the following directory structure.
.
├── app.js
└── mars
├── html.pug
└── subject.pug
It worked for me as expected.
I had this issue in a test because I was using a fake test template that didn't exist in my templates folder. It used to not throw this error on an older version (5.0.1) but now does on 9.0.0. Once I pointed it to a template that was in my templates folder the error went away.
Hello,
I've been developing my server with this package for a while now on my local machine. Today I moved my server to a digital ocean droplet, and I'm receiving the error:
Error sending register email: Error: No content was passed for subject, html, text, nor attachments message props. Check that the files for the template "register" exist.
This is really weird to me because my file system is exactly the same on my server as it is on my local machine, and it's been working fine on my local machine. My server is running Ubuntu 16.0.4.
TLDR; works fine on local, error on server, same file structure. Any ideas?
My structure:
html.pug
subject.pug
index.js
And my code in
index.js
: