forwardemail / email-templates

Create, preview (browser/iOS Simulator), and send custom email templates for Node.js. Made for @forwardemail, @ladjs, @cabinjs, @spamscanner, and @breejs.
https://forwardemail.net/docs/send-emails-with-node-js-javascript
MIT License
3.67k stars 337 forks source link

TypeError: EmailTemplate is not a constructor #267

Closed shajunr88 closed 6 years ago

shajunr88 commented 6 years ago

I am using email-templates in express js for rendering emails.But when using this library, it shows TypeError: EmailTemplate is not a constructor var EmailTemplate = require('email-templates').EmailTemplate; new EmailTemplate(templateDir);

niftylettuce commented 6 years ago

@shajunr88 you seem to be referencing 2.x version of this package. if you are, you'll need to see the docs here https://github.com/niftylettuce/email-templates/tree/2.x.

3.x was released https://github.com/niftylettuce/email-templates#v3-breaking-changes

can you confirm which version are you using?

shajunr88 commented 6 years ago

Thanks for the response .It is working now with require('email-templates-v2')

niftylettuce commented 6 years ago

@shajunr88 do not use that package -- it is not an officially supported one

instead you should do this:

npm uninstall email-templates-v2
npm install email-templates@2.x
luisk182 commented 6 years ago

I just installed the email templates and getting the same error doing this

const EmailTemplate = require('email-templates').EmailTemplate im following this example https://community.nodemailer.com/2-0-0-beta/templating/