Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What local node-version is recommended for AWS Lambda and Serverless

Starting with AWS-Lambda and the Serverless Framework i am confused about node versions:

The AWS help site says that (on 21-March-2016)

AWS Lambda supports the following runtime versions:

Node.js: v0.10.36

So i did install Node.js v0.10.36 on my local machine. Installing the latest (v 0.4.2) serverless framework via

npm install serverless -g

it gives the following warning:

npm WARN engine [email protected]: wanted: {"node":">=4.0"} (current: {"node":"0.10.36","npm":"1.4.28"})

I thought having the same version locally as on AWS might help having a consistent development environment... Am i wrong? What Node.js version should i run locally to get the most out of serverless?

like image 293
Rentrop Avatar asked Mar 12 '23 20:03

Rentrop


1 Answers

The Serverless Framework requires Node.js v4.0 or higher. Any version of Node.js within the v4.x or v5.x lines should work.

You are correct that AWS Lambda currently only supports Node.js v0.10.36. The decision to build the Serverless Framework on Node.js v4.0 was done in anticipation that AWS Lamabda would eventually support Node.js v4.0 or higher.

When developing code for AWS Lambda, you should continue to only use features compatible with Node.js v0.10.36. If you make any contributions to the framework, you can use Node.js features available in v4.0+.

Another option is to use Babelify to transform your ES2015 code uploading to AWS Lambda. This allows you to develop in ES2015 without having to wait for AWS Lambda to officially support it. This can be done automatically each time you deploy with the Serverless Framework using the Optimizer Plugin.

Update: A new option now exists, the Serverless Babel Runtime. This goes one step beyond what Optimizer does, and uses Babel inside the runtime itself.

Update 2: AWS Lambda now supports Node.js v4.3.

like image 193
Jordan Mack Avatar answered Apr 06 '23 08:04

Jordan Mack