ES6 usage requires --harmony
flag in node v0.12.3.
Is there a way to do so for an aws lambda function?
ES6 usage requires --harmony
flag in node v0.12.3.
Is there a way to do so for an aws lambda function?
You can use babel to transform es6/es7 to be compatible with node 0.10.x:
http://www.rricard.me/es6/aws/lambda/nodejs/2015/11/29/es6-on-aws-lambda.html
EDIT:
There is also a really cool AWS lambda deployer called Apex with that you can transform and deploy es6/es7 code easily! Examples: https://github.com/apex/apex/tree/master/_examples/babel-webpack
EDIT2: There is an other AWS lambda deployer called Gordon which also helps you integrate lambda with other services such as:
They also have a lot of useful examples
AWS Lambda use v0.10.36
, but anyway I think we can try in this way
var spawn = require("child_process").spawn;
var child = spawn('node', [ "--harmony", "es6.js" ], {
cwd: __dirname
});
Simple, use bluebird . Any file that requires to make use of promises, get bluebird in scope.
var Promise = require('bluebird');
Promise.aPromise()
.then(function () {
console.log('ftw!');
})
.catch(function(err) {
console.log(err, 'do not forget to catch errors. ever!');
})
As far as generators are concerned, we are out of luck. bluebird
requires minimum v0.12+
and at the time of writing lambda is still stuck in node v0.10.36
These answers are a bit out of date. AWS announced support for Node.js 4.3.2 runtime in April 2016. 4.3.2 supports ES6. It is also completely backwards compatible. More details available here:
https://aws.amazon.com/blogs/compute/node-js-4-3-2-runtime-now-available-on-lambda/