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

SyntaxError: Unexpected token #247

Closed lukazlatecan closed 7 years ago

lukazlatecan commented 7 years ago

When i try to use your module, I get the following error: node_modules/email-templates/index.js:86 return new Promise(async (resolve, reject) => { ^ SyntaxError: Unexpected token (

OmgImAlexis commented 7 years ago

What node version are you using?

atomdmac commented 7 years ago

I'm seeing this error with node v7.3.0. My assumption is that I'll either need to upgrade to a newer version of node or introduce an additional compilation step.

niftylettuce commented 7 years ago

@atomdmac You need the latest version of 7.x. 7.10.1 for example should work.

This is b/c this package uses async/await http://node.green/#ES2017-features-async-functions-await and your version does not support it.

niftylettuce commented 7 years ago

Currently you will need to upgrade to v8.3.x+ due to a dependency @ladjs/i18n requiring object rest spread at https://github.com/ladjs/i18n.

sabinthomas commented 7 years ago

If we downgraded to v2 of email-templates, would that run on Node v6 LTS?

niftylettuce commented 7 years ago

Yes should be fine @sabinthomas - I'm going to add support for Node v6 of email-templates@3.x today though...

darbio commented 7 years ago

I get the same issue when running on AWS lambda nodejs6.10.

Did you add this in yet?

I'm using "email-templates": "^3.1.0"

niftylettuce commented 7 years ago

We are not going to support Node v6 with v3+ of this package. It's incredibly easy to upgrade Node versions (e.g. use https://github.com/creationix/nvm). I use solutions like this in production all the time as well and have experienced zero issues. As of email-templates@3.1.2 we now support node >= 7.6.0, however I'd recommend upgrading to latest stable node so you get access to features like async/await, promises, object rest spread, etc.

Ref: http://node.green/

niftylettuce commented 7 years ago

Also if you need a guide for upgrading from v2 to v3 (and you're on Node >=7.6.0) then see https://github.com/niftylettuce/email-templates#v3-breaking-changes.

niftylettuce commented 7 years ago

Also hopefully to prevent other users from this headache, I've added a note regarding Node v7.6.0+ requirement to README per https://github.com/niftylettuce/email-templates/commit/5260d65d56c259af8d58ddbaee6912da13463d16.

darbio commented 7 years ago

If you transpile the code before packaging for npm you can keep the niceness of async etc. without needing people to upgrade their node versions. For some (e.g . AWS lambda, enterprise users etc.) upgrading node from LTS to a newer version is just not possible.

niftylettuce commented 7 years ago

I don't want to support Node 6, I'm sorry. Using a transpiler is much worse than upgrading Node. 8.x LTS support starts 10/31/17 anyways, which is a week away. https://github.com/nodejs/Release#release-schedule1

darbio commented 7 years ago

That's all good mate - I get it, and being your library is totally your prerogative to choose how/what you want to do. I am just providing feedback outside what you have thought about - I know sometimes I need an external opinion to ensure I make the best decision.

I would hate for a good library such as this to cut out its current and future user base because of node version updates which provide features already available through use of transpilers.

Node 8 might be LTS soon, but that doesn't mean that people will upgrade to it in prod. History has shown this.

Just my two cents and you can do with them what you please :)

niftylettuce commented 7 years ago

I'll add node v6 support, you've made your case and I reckon a ton others want this... one moment.

niftylettuce commented 7 years ago

My main reason for doing this is because babel-preset-env makes it very easy to target a specific node version to support. This really didn't exist when I was using babel heavily.

darbio commented 7 years ago

Excellent! I'll test tomorrow :+1:

niftylettuce commented 7 years ago

@darbio I will ping you with a release version for you to try, I am finishing it now.

niftylettuce commented 7 years ago

@darbio can you please try v3.1.5? npm install email-templates@latest or yarn add email-templates@latest. this package now supports Node v6.4.0+. I've also updated README with this note that v6.4.0+ is a requirement (instead of 7.x)

darbio commented 7 years ago

I will install tonight. Thanks for implementing this :)

darbio commented 6 years ago

@niftylettuce I've tested this on AWS lambda and it now works in that environment (node 6.10). Thanks for implementing this!

niftylettuce commented 6 years ago

glad to hear. thank you

On Mon, Oct 23, 2017 at 6:50 PM, darbio notifications@github.com wrote:

@niftylettuce https://github.com/niftylettuce I've tested this on AWS lambda and it now works in that environment (node 6.10). Thanks for implementing this!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/niftylettuce/email-templates/issues/247#issuecomment-338819331, or mute the thread https://github.com/notifications/unsubscribe-auth/AAf7heM3qZwOw1ekKWejsufBetCegDvXks5svRgpgaJpZM4Pxrvy .

-- @niftylettuce