Using async keyword in AWS Lambda

Question:

I am playing with AWS Lambda using Node.js. After being tired of having to deal with callbacks I figured I could elegantly use async/await just like I am used to in C#.

Even though this seemingly works when testing offline using lambda-local, it fails miserably when uploaded to AWS. It appears as if async keyword is not recognized. I am using the latest Node.js 6.10 runtime on AWS while my local version is 8.5. Is there a way around or should I abandon this approach and go back to using callbacks?

Answer:

The async/await feature was launched in Node.js v7.0 but was behind the --harmony flag as it was experimental. It was fully supported without the flag after Node.js v7.6.

Hence, you can’t use async/await with Node.js v6.10.

Look here to know exactly which versions are supported.

Leave a Reply